144
rated 0 times
[
145]
[
1]
/ answers: 1 / hits: 17340
/ 13 Years ago, fri, july 1, 2011, 12:00:00
If an image doesn't exist, or somehow an image just doesn't load, is there a way to make it so this message doesn't show up in the web inspector?
Failed to load resource: the server responded with a status of 403 (Forbidden)
I have tried these:
<img src=/path.png onerror=this.src = '/missing.png'; this.onerror = ''; return true;/>
<img src=/path.png onerror=this.src = '/missing.png'; this.onerror = ''; return false;/>
And I've tried it in jQuery:
$(document).ready(function() {
$(img).error(function(event) {
$(this).attr(src, /missing.png);
return false;
}
});
That message gets output in red before any of these event handlers get access to it, is there not a way to prevent this message from showing up?
Ideally, I would be able to do this:
$(img).live(error, function() { $(this).attr(src, /missing.png); });
so I don't have to:
- Write inline javascript like
<img onerror='x'/>
- and it would work on dynamically loaded images.
More From » html