javascript - Getting rid of the "Failed to load resource: the server responded with a status of 403 (Forbidden)" message when an image fails to load? -
if image doesn't exist, or somehow image doesn't load, there way make message doesn't show in web inspector?
failed load resource: server responded 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 in jquery:
$(document).ready(function() { $("img").error(function(event) { $(this).attr("src", "/missing.png"); return false; } });
that message gets output in red before of these event handlers access it, there not way prevent message showing up?
ideally, able this:
$("img").live("error", function() { $(this).attr("src", "/missing.png"); });
so don't have to:
- write inline javascript
<img onerror='x'/>
- and work on dynamically loaded images.
unfortunately need check existence of image prior adding <img>
dom. check have occur server-side far know; attempting jquery/ajax still result in 404 or 403 error appearing in console.
Comments
Post a Comment