Click to See Complete Forum and Search --> : need a simple code check please


xdementia
03-11-2003, 04:35 PM
hi, I am using this simple javascript that I got off the internet for multiple thumbnails that open in larger windows to show the full image. The problem is, when someone clicks on the thumbnail to view it for the first time, it works fine, it pops up in a new window that is the right size, however, if the click another image without closing the new window, the second image will pop up into the same window that the first image opened in, which will most likely not be the right size for the new pic. Here's my code, I'm assuming this is a simple fix, I just can't figure it out.
thanks,
-egan

<head>
<title>Shows</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT language="JavaScript">
<!-- hide from JavaScript-challenged browsers
function openWindowfront() {
popupWin = window.open('front.htm', 'remote', 'width=300,height=299')
}
function openWindowdemo() {
popupWin = window.open('demo.htm', 'remote', 'width=200,height=200')
}
// done hiding -->
</SCRIPT>
</head>

then i call the functions like this:
<A HREF="javascript:openWindowfront('front.htm');"><img src="frontthumb.jpg" width="60" height="60" border="0"></a>

and

<A HREF="javascript:openWindowdemo('demo.htm');"><img src="demofrontthumb.jpg" width="60" height="60" border="0"></a>

pyro
03-11-2003, 04:42 PM
Yup, quite easy...You named both the windows remote, which makes the images popup in the same window.

khalidali63
03-11-2003, 04:47 PM
Just and addition to Pyros message...


create a variable say
var ctr=0;

and then in your code add the variable with name

function openWindowfront() {
popupWin = window.open('front.htm', 'remote'+ctr, 'width=300,height=299')
}

this will give every window a unique name and hence a new window every time..tadaa..

Cheers

Khalid

Nedals
03-11-2003, 06:53 PM
Do you want multipule windows or would you prefer that the open window automatically closes when you try to view another image.

Like this....
var imgWin = null;
if (imgWin && !imgWin.closed) { imgWin.close() }
imgWin = window.open("","imgWindow","width="+W+",height="+H);

If you preload your images into an array you could also get the image width and height to set your window dimensions.