要显示//www.gravatar.com/avatar.php?gravatar_id=67138854fb7b05744ff87e59bea9a876&size=60&default=http%3A%2F%2Fwww.myimkkk.com%2Fpublic%2Fimages%2Fcommon%2Fnoemail.jpg
如果图片不存在时将触发onerror事件,显示后面指定的/public/images/common/noemail.jpg
有时候,一些问题的解决方法 还是的去看官方文档
I am using the following method to replace missing images with a placeholder img. Works fine, except in Firefox. Any ideas why FF doesn't detect the error?
$(function(){ $('#id img').error(function() { $(this).attr('src','placeholder.jpg'); }); }); Also tried .bind('error', handler) with the same results.
Are you working locally?
Docs say it might not work when using local...
//api.jquery.com/error/
In Firefox imgObject.onerror handler is intentionally killed in any form, even for hardcoded in the source elements (internal security exception raised) - maybe to prevent any possibility of content sniffing or I don't know. AFAICT nothing you can do about it. Either screw on Firefox, or move your logic server-side which is suggested: so get directory check results from server script over some ajaxoid.
52朵
0个