Getting Image Width/Height

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emilmgeorge
    New Member
    • Dec 2006
    • 2

    Getting Image Width/Height

    Pls somebody give me the code for getting the height and width of a image in pixels in javascript or asp.

    Thanks
    - Emil
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    As an example
    [HTML]<html>
    <head>
    <script type="text/javascript">
    function getSize() {
    var height = document.getEle mentById("image ").height;
    var width = document.getEle mentById("image ").width;
    alert("Height: "+height+ ", width: "+width);
    }
    </script>
    </head>

    <body>
    <img id="image" src="whatever.g if">
    <form>
    <input type="button" onclick="getSiz e()" value="Get image size">
    </form>
    </body>

    </html>[/HTML]

    Comment

    Working...