2012-02-20 25 views
1

工作jQuery的事件中,我試圖捕捉事件orerror在image.I有代碼.error不IE8

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

在谷歌Chrome,Mozilla的,IE9一切就OK了,但是IE8它不工作。請問你能幫幫我嗎!!!

+2

被顯示在IE8什麼錯誤?任何JavaScript錯誤?看起來在IE8中支持 - > http://www.quirksmode.org/dom/events/error.html – ManseUK 2012-02-20 10:25:39

+1

這些行有什麼意義? 'var src = image.attr('src'); image.attr(「src」,src);'? – 2012-02-20 10:26:08

+0

你在本地測試嗎? – Baz1nga 2012-02-20 10:28:51

回答

1

僅供參考,從錯誤jQuery的API文檔():

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.