jquery事件.error在IE8中不起作用

时间:2012-02-20 10:23:14

标签: javascript jquery javascript-events

我尝试在图像中捕获事件orerror。我有代码

var image = $("#imgBrandDescription img");
var src=image.attr('src');
image.attr("src",src);
image.error(function(){
   $(this).hide();
}

在谷歌浏览器,Mozilla,IE9一切正常,但IE8不起作用。请你帮帮我!!!

1 个答案:

答案 0 :(得分:1)

仅供参考,来自jQuery API docs for error():

This event may not be correctly fired when the page is served locally. Since error relies
on normal HTTP status codes, it will generally not be triggered if the URL uses the file:
protocol.