The size of the picture displayed in the browser is not necessarily his true height and width, like the following, we give him a wide and high style
The size shown in the browser is 25px. So how do we get the real size of the picture? , the following code implements this functionality
Copy Code code as follows:
<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8" >
<body>
<script>
Set time delay to ensure picture loading complete
settimeout (function () {
Var
Real_width,
Real_height,
_im = document.getElementById (' image '),
im = document.createelement (' img ');
IM.SRC = _im.src,
Real_width = Im.width,
Real_height = Im.height;
Alert (real_width+ ' \ n ' +real_height);
},500);
</script>
</body>
Note: The above code I have tested on ie7+ and chrome, because there is no IE6, so can not test.
Very good code, I most of the projects are in use, we rest assured that use it