Browser Compatibility - setting image source and height/width

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Super santhosh

    #1

    Browser Compatibility - setting image source and height/width

    Hi,
    Am using

    Code:
    var newImg = new Image();
    newImg.src = imgSrc;
    var height = newImg.height;
    var width = newImg.width;
    This code runs fine in IE but fails in Mozilla.

    Can any one suggest me to solve this problem, making compatible with different browsers...


    thanks

    Santhosh
    Last edited by Dormilich; Nov 10 '10, 02:30 PM. Reason: please use [CODE] [/CODE] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I suppose you want to have the dimensions of the image?

    in Mozilla browsers you can use Image.naturalWi dth/Image.naturalHe ight.

    Comment

    • JKing
      Recognized Expert Top Contributor
      • Jun 2007
      • 1206

      #3
      Is there anything else to this script?

      imgSrc is not defined. That is your error in firefox.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        I suppose that is just a part of the script. imgSrc may be defined somewhere else.

        Comment

        Working...