Javascript examples for DOM HTML Element:Image
Image naturalHeight Property - difference between the naturalHeight property and the height property:
<!DOCTYPE html> <html> <body> <img id="myImg" src="http://java2s.com/resources/a.png" style="width:107px;height:500px;"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <p id="demo2"></p> <script> function myFunction() {// w w w.j a v a 2s. c om var x = document.getElementById("myImg").naturalHeight; document.getElementById("demo").innerHTML = "The original height of the image is: " + x + " pixels"; var y = document.getElementById("myImg").height; document.getElementById("demo2").innerHTML = "The 'styled' height of the image is: " + y + " pixels"; } </script> </body> </html>