Click to See Complete Forum and Search --> : Updating size of new window
bunner bob
01-13-2003, 04:58 PM
I've got javascript generating a new window with a full-size image whenever a user clicks on an image thumbnail. The first click works fine, but subsequent clicks don't regenerate the window with the new size settings for the new image. The relevant part of the code looks like this:
function pictureWindow(img_name,width,height) {
newWindow = window.open("", "newWin", "toolbar=no,status=no,location=no,scrollbars=no,title=no,menubar=no,resizable=no,width=" + width + ",height=" + height + "");
}
Each thumbnail sends the appropriate img_name, width and height settings. How do I get the window to "reset" so it uses the new width and height rather than the existing ones?
ThankS!
Hmm.. is that your FULL code? What is the code in the main page that controls the remote?
bunner bob
01-13-2003, 05:22 PM
Well the link actually looks like this:
echo "<a href=\"javascript:pictureWindow('" . $img_name . "','" . $popupwidth . "','" . $popupheight . "')\">";
echo "<img src=\"images/progthumbs/thumbfile" . $i . ".jpg\" border=\"0\" align=\"right\"></a>";
but when you strip the php, it goes:
<a href="javascript:pictureWindow('eggs.jpg','450','250')"><img src="images/progthumbs/thumbfile1.jpg" border="0" align="right"></a>
<a href="javascript:pictureWindow('ham.jpg','250','150')"><img src="images/progthumbs/thumbfile2.jpg" border="0" align="right"></a>
(more or less)
I tried dropping the single quotes around the width & height but it doesn't seem to make a difference.
bunner bob
01-13-2003, 05:24 PM
Weird - this board breaks up "javascript" into "java" "script" (with a space) - I didn't type it that way!
OK, I know why the board does this. When I send/receive messages at my yahoo.com email address, it always changes JavaScript to, _JavaScript, and VBScript to _VBScript. And at mail.com, it changes <SCRIPT> to <xScript>...
It is because the board uses JavaScript as well. They use it for many things, and since we're posting messages, the serverside language (in this case PHP, but yahoo and mail.com use CGI) cannot parse "JavaScript" without returning with an error. So it is told that if it comes across, "javascript" to change it to, "java script."
I just figured something out! It is only that way when you use, "javascript:" with the colon...
AdamBrill
01-13-2003, 05:52 PM
Try taking a look at this code and see if it helps:
<html>
<body>
<script language=javascript>
test=null;
function open_window()
{
if(!test)
{
test = window.open("","test","width=100px; height=100px;");
}
else
{
test.close();
test = window.open("","test","width=100px; height=100px;");
}
}
</script>
</body>
<a href="javascript:open_window()">test</a>
</html>
What it does is check if the window is open. If it is, it closes it before it opens it again. That way, you can change the size. I hope that helps...
bunner bob
01-15-2003, 07:13 PM
Well - I tried it and part of it works. Clicking the first link opens the first window, then clicking the second link closes it but doesn't open the second window.
Is there a way to just open a new, different window instead of targeting the same window?
My code looks like this at the moment:
function pictureWindow(img_name,width,height) {
newWindow = window.open("", "newWin", "toolbar=no,status=no,location=no,scrollbars=no,directories=no,menubar=no,resizable=no,width=" + width + ",height=" + height + "");
newWindow.document.write("<html><head><title>" + img_name + "<\/title><\/head><body bgcolor=\"#ffffff\" leftmargin=\"0\" marginwidth=\"0\" topmargin=\"0\" marginheight=\"0\" ><img src=\"images\/progimages\/" + <?php echo $progid ?> + "\/" + img_name + "\"><\/body><\/html>");
newWindow.document.close();
}
AdamBrill
01-16-2003, 08:19 AM
It doesn't work all the time for you? What browser are you using? For me, it works great in IE6, and works except for the width and height in netscape 4.7, netscape 7, and Opera 7. If the only thing that isn't working right is the width and height, there is a work around for that. I can't remember it right off hand, but I could probably get it for you if you want it.
bunner bob
01-16-2003, 12:51 PM
Yeah, it consistently doesn't work (or does work in the way I specified - closes first window, doesn't open second). I'm using IE 5.22 for Mac OS X. Oh well, another lovely javascript incompatibility. Guess I'll just skip the close() bit - as long as the user closes the first window the second one opens fine and sized correctly.