The browser does NOT provide a special event that will inform you as soon as possible that it knows the size of the image (before it finishes downloading the image). All you can do is set up an appropriate load handler to find out when the image has finished loading, and then its size is known.
, , .width .height. this jsFiddle Chrome onload(). .
onload .src HTML- , , , , - :
<img src="xxx.jpg" onload="handleLoad(this)">
javascript ( , ). (, , ).
( , javascript), .
var img = new Image();
img.onload = function() {
};
img.src = "xxxx.jpg";
: onload, .src. IE, , , .src , , .src, onload, onload .