View Full Version : window size of pic?
Jon Dapron
12-30-2003, 10:33 AM
Hi,
When you click on a thumbnail, is there any way to have the window open up to the size of the picture being opened, when the pics all vary in size?
bassrek
12-30-2003, 11:28 AM
You'll have use the window.open method in Javascript and then pass the actual image dimensions to it within your <a> tag similar to this:
//Javascript function...
function OpenIt(thePic,theW, theH) {
window.open(thePic,"NewWindow","width="+theW+",height="+theH)
}
//within your HTML document...
<a href="javascript:OpenIt('Image.jpg',100,100)"><img src="Image-thumb.jpg" width="50" height="50" alt="Some Picure"></a>
You cannot dynamically grab the dimensions of the images to pass to Javascript using just HTML.
Jon Dapron
12-30-2003, 11:38 AM
Thanks for the response!
Where is the best place to put the javascript code in this situation? And can you remind me of the opening/closing tags for js code? Thanks in advance!
bassrek
12-30-2003, 11:42 AM
You'd put it inside of your <head> tag like
<head>
<!--other head stuff up here...-->
<script language="Javascript">
<!--
function OpenIt(thePic,theW, theH) {
window.open(thePic,"NewWindow","width="+theW+",height="+theH)
}
-->
</script>
</head>
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.