In the handler of OnLoadmy webpage, I am trying to check if all the images are loaded correctly.
I repeat all the tags <img>and test them using my function isImageLoaded(). Unfortunately, my function only works with Firefox and IE up to version 8.
Any suggestions how can I get it to work in IE 9 and 10?
function isImageLoaded(img) {
if (!img.complete) {
return false;
}
if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
return false;
}
return true;
}
Update: It turned out that the main culprit is that OnLoad can be launched before all images load IE9 +. What would be the best trigger for checking images on a page? I would rather check them all at once, rather than with separate OnLoad / OnError handlers.
source
share