img.height for Internet Explorer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajesk
    New Member
    • Oct 2006
    • 2

    img.height for Internet Explorer

    Hi
    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.setTimeo ut 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.
    Last edited by rajesk; Mar 22 '08, 07:46 AM. Reason: more details provided
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Try calling from img.onload.

    Comment

    • rajesk
      New Member
      • Oct 2006
      • 2

      #3
      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:

      [CODE=javascript]var newImageObj = new Image();
      if (img != null)
      {
      newImageObj.src = img.src;
      return newImageObj; //this object contains height
      }
      else
      {
      return img;
      }[/CODE]
      Last edited by gits; Mar 26 '08, 10:33 PM. Reason: added code tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        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.

        Comment

        Working...