View Full Version : image size
rsstewart
10-24-2002, 02:27 PM
Is there a simple way to determine an image's size?
example:
image1= "\images\photo1.jpg" (or a variable I set)
myheight= image1.height
mywidth = image1.width
<img src=image1, width=mywidth, height=myheight>
Roelf
10-24-2002, 02:38 PM
change it to:
image1= new Image();
image1.src = "\images\photo1.jpg" (or a variable I set)
myheight= image1.height
mywidth = image1.width
then document.write the image tag (or add it to
rsstewart
10-24-2002, 05:52 PM
Ok. great. now is there a way to make that image open a new window that size in the foreground, and show the picture in it?
Roelf
10-24-2002, 06:47 PM
yes there is, try doing a search in this forum at window.open or something like that. It should bring up enough info
rsstewart
10-24-2002, 09:31 PM
Hey! I got it to work. except that it only work when I click the first one. Now I need to know how to change the size of an existing window....
Roelf
10-24-2002, 10:01 PM
try looking at http://www.devguru.com/Technologies/ecmascript/quickref/window.html method resizeTo
rsstewart
10-25-2002, 03:16 PM
http://www.chroofing.com/metal_featured_casa1.htm
view this page. It works great the SECOND time you click the thumbnail. The first time I click a thumbnail, it pulls it up in a very small window. I can't figure out why. If anybody can help me finish this, I would really appriciate it.
Thanks.
Roy Sinclair
10-25-2002, 10:00 PM
Originally posted by rsstewart
http://www.chroofing.com/metal_featured_casa1.htm
view this page. It works great the SECOND time you click the thumbnail. The first time I click a thumbnail, it pulls it up in a very small window. I can't figure out why. If anybody can help me finish this, I would really appriciate it.
Thanks.
I would guess that this line: if (! window.focus)return true; is executing the first time you click the link.
rsstewart
10-25-2002, 10:37 PM
That didn't seem to fix it...
I had a thought:
Does the picture need to be loaded for my script to read the height and width?
If so, this would explain why it never works until you've clicked the picture once. How can I get the picture properties before the image loads, or to wait to resize it until after the pitcure loads?
rsstewart
10-29-2002, 11:39 AM
anybody?
Roelf
10-29-2002, 03:08 PM
Originally posted by rsstewart
Does the picture need to be loaded for my script to read the height and width?
yes it does, the browser has to have the picture loaded, before it can determine the size of it
Roelf
10-29-2002, 03:11 PM
Originally posted by rsstewart
If so, this would explain why it never works until you've clicked the picture once. How can I get the picture properties before the image loads, or to wait to resize it until after the pitcure loads?
use the Image.complete property combined with a loop to determine if the image is loaded
Image.complete is documented here
http://www.devguru.com/Technologies/ecmascript/quickref/image.html
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.