The size of the image displayed in the browser may not be its actual height and width. For example, as shown below, we add width and height styles to it
The size displayed in the browser is 25px. So how do we get the true size of the image? , the following code implements this function
//Set a delay to ensure that the image is loaded
setTimeout(function() {
var
real_width,
real_height,
_im
through
real_width = im.width,
real_height = im.height;
alert(real_width 'n' real_height);
},500);
Note: I have tested the above code on both IE7 and chrome. Since IE6 is not installed, I cannot test it.
Very easy to use code, I use it in most of my projects, feel free to use it
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn