SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Image-sized popup
-
May 16, 2002, 10:24 #1
- Join Date
- Dec 2000
- Location
- Louisiana
- Posts
- 107
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Image-sized popup
Hi peeps!
I want to be able to do this:
Have some thumbnails that when clicked, pops up the full-sized image.
The thing is this: Each image will be a different size.
I want the pop-up window to have the dimension of each full size image with no padding, etc...
So what's the best solution to this in javascript?
Thanks.
// -->rocko"If it's taking up my time, then it must be good!" -Rocko
-
May 16, 2002, 10:53 #2
- Join Date
- Jan 2001
- Location
- Lawrence, Kansas
- Posts
- 2,066
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try this:
Code:<script> function imageClicked(img) { height = img.height; width = img.width; src = img.src; window.open(src,"img_window","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+width+",height="+height) } </script> <img src="image.gif" onClick="imageClicked(this)"> <img src="anotherimage.gif" onClick="imageClicked(this)">
-
May 16, 2002, 11:15 #3
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
this will not work properly, as it will get the image size of the minimised image, so
what you should do is preload the larger images as well and for each one use the script above to store the values in a array
http://www.webmasterbase.com/article/625/72
i did have something similar, but i wont be able to find it right now.
basically you can do some validation if the image exists or fails via
if (img.width <= 200 || img.height <= 100 || img.complete() != true)
{
//.. do this popup instead
}
-
May 16, 2002, 11:29 #4
- Join Date
- Dec 2000
- Location
- Louisiana
- Posts
- 107
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Still....
Thanks for the reply.
ALl that did was popup the thumbnail itself
The full-size image is has to be different than the thumbnail
Thanks again, sorry for the mess-up.
// -->rocko"If it's taking up my time, then it must be good!" -Rocko
-
May 16, 2002, 13:32 #5
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:function imageClicked(img) {
height = img.height;
width = img.width;
if (height == undefined || width == undefined) alert('no value');
tools = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + width + ',height='+height;
window.open(img,'img_window',tools)
}
-
May 16, 2002, 20:15 #6
- Join Date
- Jan 2002
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try this one..
Bookmarks