ecoli
08-19-2004, 06:30 AM
hi,
i am adapting someone else's script, as i am not yet fluent in javascript, and need to modify one small part...
basically it's an image gallery script with popup windows launched by clicking on a thumbnail. if the popup window is open, and the user clicks on a different thumbnail, i want the existing popup to close and the new one open. i think it's already supposed to do this, but when you click on a thumbnail, the open one closes, but the new one does not open.
function popupgalimage(imgsrc, popwidth, popheight){
function triangulate(){
leftpos = (screen.width) ? (screen.width-popwidth)/2 : 0;
toppos = (screen.height) ? (screen.height-popheight)/2 : 0;
}
triangulate()
var windowdesc='width='+popwidth+',height='+popheight+',resizable=no,left='+leftpos+',top='+toppos
var picsrc='popwin.php?file='+imgsrc
if (typeof popupgalwin=="undefined" || popupgalwin.closed)
popupgalwin=window.open(picsrc,"popupgalwin",windowdesc)
else{
popupgalwin.close()
popupgalwin=window.open(picsrc,"popupgalwin",windowdesc)
}
}
to me it looks like the last two lines there say if a window is already open, then close popupgalwin, then open a new popupgalwin with the necessary file/parameters. however, it just closes the one and then doesn't open the other.
i tried a few things, but i like i said i'm not good enough to do this on my own yet. :)
thanks
skye
i am adapting someone else's script, as i am not yet fluent in javascript, and need to modify one small part...
basically it's an image gallery script with popup windows launched by clicking on a thumbnail. if the popup window is open, and the user clicks on a different thumbnail, i want the existing popup to close and the new one open. i think it's already supposed to do this, but when you click on a thumbnail, the open one closes, but the new one does not open.
function popupgalimage(imgsrc, popwidth, popheight){
function triangulate(){
leftpos = (screen.width) ? (screen.width-popwidth)/2 : 0;
toppos = (screen.height) ? (screen.height-popheight)/2 : 0;
}
triangulate()
var windowdesc='width='+popwidth+',height='+popheight+',resizable=no,left='+leftpos+',top='+toppos
var picsrc='popwin.php?file='+imgsrc
if (typeof popupgalwin=="undefined" || popupgalwin.closed)
popupgalwin=window.open(picsrc,"popupgalwin",windowdesc)
else{
popupgalwin.close()
popupgalwin=window.open(picsrc,"popupgalwin",windowdesc)
}
}
to me it looks like the last two lines there say if a window is already open, then close popupgalwin, then open a new popupgalwin with the necessary file/parameters. however, it just closes the one and then doesn't open the other.
i tried a few things, but i like i said i'm not good enough to do this on my own yet. :)
thanks
skye