469,327 Members | 1,261 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

img.height for Internet Explorer

Issue: IE 7/Win XP
Works for FF2.0/Win XP

I am loading bunch of images on web page, I am in need of img.height property but it is coming as 0 for the Internet Explorer 7. It works as expected for FireFox 2.0 and am I not sure how can I resolve the same. I am preloading the images as well but it is of no use. I am providing window.setTimeout for giving time for image to load but that does not help either. The
img.complete comes as false, while img.readystate == "complete" comes as true.

Any help would be appreciated.
Mar 22 '08 #1
3 1460
16,027 Expert Mod 8TB
Try calling from img.onload.
Mar 22 '08 #2
Thank you for the response. I sincerely appreciate it. I am using onload to load the javascript method on the image. The way I was able to resolve this issue is, I am verifying for img.complete and then copying the src and return the new object. So snippet:

Expand|Select|Wrap|Line Numbers
  1. var newImageObj = new Image();
  2. if (img != null)
  3. {
  4.    newImageObj.src = img.src;
  5.    return newImageObj;  //this object contains height   
  6. }
  7. else
  8. {
  9.   return img; 
  10. }
Mar 26 '08 #3
16,027 Expert Mod 8TB
I see you've got it working with the complete property. The alternative as I suggested earlier is the onload before you set the src property.
Mar 27 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

12 posts views Thread by Robert Mark Bram | last post: by
2 posts views Thread by Marek Mnd | last post: by
10 posts views Thread by Roderik | last post: by
3 posts views Thread by TheXenocide | last post: by
reply views Thread by Jean Pierre Daviau | last post: by
4 posts views Thread by rfox | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.