Image Replacement (JS/JQuery) working in IE but not FF

Posted by Sunburnt Ginger on Stack Overflow See other posts from Stack Overflow or by Sunburnt Ginger
Published on 2011-03-16T15:35:34Z Indexed on 2011/03/16 16:10 UTC
Read the original article Hit count: 180

I have tried multiple solutions for replacing broken images (both JS & jQuery) and all work perfectly with IE but not in FF, is there a reason for this?

Are images handled differently in FF that may cause this?

JQuery Example:

$("img").error(function(){
  $(this).unbind("error").attr("src", "nopic.jpg");
});

Javascript Example: (triggered by onError event in img tag)

function noimage(img){
   img.onerror="";
   img.src="nopic.jpg";
   return true; }

Both of these examples work perfectly in IE but not at all in FF. What gives?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery