Image naturalWidth Property
Return the original width of an image:
The result of x will be:
Definition and Usage
The naturalWidth property returns the original width of an image.
For example, if you have an image that is originally 100 pixels wide. Then, you style the image with CSS/or by using the HTML "width" attribute to make it 500 pixels wide. The naturalWidth property will return "100", the width property however, will return 500.
Note: This property is read-only.
The naturalWidth property is supported in all major browsers.
Note: The naturalWidth property is not supported in Internet Explorer 8 and earlier versions.
|Return Value:||A Number, representing the original width of an image in pixels|
The difference between the naturalWidth property and the width property:
var y = document.getElementById("myImg").width;