The original code (360 security browser speed mode is not compatible)
function Imgauto (i, MAXW, maxh) {var o = new Image (); O.SRC = I.SRC; var w = o.width;//w equals null, the problem does not appear on other browsers}
The picture needs to be reloaded again.
function Imgauto (i, MAXW, maxh) {var o = new Image (); O.onload = function () {var w = o.width; } O.SRC = I.src;}
Note:
Write the onload to the front, first tell the browser how to handle the picture, and then specify the source of the image, so as to avoid IE compatibility issues.
IE will cache the picture, the 2nd load of the picture, not uploaded from the server, but from the buffer load, not IE did not trigger the OnLoad event, but because the speed of loading the buffer is too fast, so that when not running to Img.onload, the onload event has been triggered. This makes me think of Ajax, when writing XMLHTTP, is the first to specify the Onstatechange callback function, and then send the data, the truth is the same.
JS Picture upload compatibility issue (get picture width is high compatible)