PDA

View Full Version : Opening new window


VatoElvis
11-15-2002, 03:18 AM
I have created a gallery of sorts with thumbnails. I want the thumbs, when clicked, to open a new window.

Here is the code that I am using:


function openWindow() {
popupWin = window.open('http://www.domainname.com/imagename.jpg', 'blank', 'menubar,toolbar,location,directories,status,dependent,width=640,height=480')
}


Here's my question...

I'd really like to have the window open to the width and height of each photo and not to a static, pre-set dimension.

Is this possible, and if so, how is it accomplished?

Thanks in advance,
Marc

glenngv
11-15-2002, 03:27 AM
function openWindow(url,target,w,h) {
popupWin = window.open(url, target, 'menubar,toolbar,location,directories,status,dependent,width='+w+',height='+h);
popupWin.focus();
}


then call it like this:

<a href="http://www.domainname.com/imagename.jpg" target="imagename" onclick="openWindow(this.href,this.target,640,480);return false;"><img src="http://www.domainname.com/imagename.jpg" border="0"></a>
<a href="http://www.domainname.com/imagename2.jpg" target="imagename2" onclick="openWindow(this.href,this.target,800,600);return false;"><img src="http://www.domainname.com/imagename2.jpg" border="0"></a>
<a href="http://www.domainname.com/imagename3.jpg" target="imagename3" onclick="openWindow(this.href,this.target,640,480);return false;"><img src="http://www.domainname.com/imagename3.jpg" border="0"></a>

this degrades well with javascript disabled browsers coz the image will still be opened in a new normal window.