Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript & Images

Status
Not open for further replies.

Liquid

Programmer
Sep 16, 2000
2
CA
Is there a way to read (or get) an image's size (before loading preferably) using Javascript (or any other means) [sig][/sig]
 
In javascript, you can get the width and height for an image like this:

w=document.images
.width;
h=document.images
.height;

This works with netscape 3+ and IE 4+

You can't get these attributes before the document loads with client-side scripting. However, you can retrieve them in the onLoad event. If you _really_ need to know before the document loads, it can be done with server-side scripting.

Regards,
[sig]<p>Russ<br><a href=mailto:bobbitts@hotmail.com>bobbitts@hotmail.com</a><br><a href= is in</a><br>[/sig]
 
thanx but this is not really what i want to do see

what i want is to preload images in an array using new Image
and id like to put the size in new Image(x,y) so that it can do changes to the page faster

now if this does not matter at all when you're using new image please inform me cause i know it does when u use <IMG>

JB [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top