Is it possible somehow to check is image loaded without function .load() or onLoad? Problem is that the webkit-like browsers doesn't work properly with this function.
UPDATE: Problem is in - load fires only once otherwise stream is going and loading new images.
Is it possible somehow to check is image loaded without function .load() or onLoad? Problem is that the webkit-like browsers doesn't work properly with this function.
UPDATE: Problem is in http://en.wikipedia/wiki/Motion_JPEG - load fires only once otherwise stream is going and loading new images.
Share Improve this question edited Sep 7, 2012 at 13:28 Andresh Podzimovsky asked Sep 7, 2012 at 13:05 Andresh PodzimovskyAndresh Podzimovsky 1,5614 gold badges13 silver badges17 bronze badges 5-
2
The
.plete
boolean property will tell you if the image is loaded. Soif ( img.plete ) { ... }
. (Note, though, that it probably isn't implemented in IEold.) – Šime Vidas Commented Sep 7, 2012 at 13:16 - Webkit browsers support the "load" event for images. What do you mean? – Šime Vidas Commented Sep 7, 2012 at 13:21
- They do not fire the event if the image is ing from cache. – vinczemarton Commented Sep 7, 2012 at 13:21
- @SoonDead Yes. Browsers generally behave like that. – Šime Vidas Commented Sep 7, 2012 at 13:23
- If I remember correctly IE-s don't. – vinczemarton Commented Sep 7, 2012 at 13:24
2 Answers
Reset to default 4You can check img.width
: it's 0 if it's not loaded.
But I'm sure you can use onload
(all low cap) on webkit browsers too :
img.onload=function(){
console.log('loaded!');
};
img.src='something';
Beware a frequent error : you have to set the src after you set the onload, or the onload callback won't be called if the image is in cache.
Demonstration : tested on Chrome, which is webkit based
I used this https://github./desandro/imagesloaded in a project and it worked fine for me