I have a query calling a bunch of such images:
<a href='www.domain1.com'><img src='../image/img1.png' onerror='imgError(this);'/></a>
<a href='www.domain2.com'><img src='../image/img2.png' onerror='imgError(this);'/></a>
The problem is that during the call some images (~ 20%) are not ready yet. They need another second.
So, in js or jquery, what I would like to do is the error of getting images that failed, wait 1 second, and then try loading these failed images again. If they fail in the second attempt - well, I'm good with that. But I am not doing it right ... Should I not call the timeout inside another method in js?
function imgError(image) {
image.onerror = "";
image.src = image;
setTimeout(function () {
return true;
}, 1000);
}
source
share