2012-02-11 121 views
0

我加載圖像到空白標籤,並不斷收到以下IE 7錯誤:reader.load - >錯誤載入圖像:http://localhost/uploads/239-4/SCAN_0001.jpgIE 7 jQuery的圖像加載錯誤

我跑的jQuery 1.7.1和下面的加載圖像:

prop.image.attr('src', 'http://localhost/uploads/239-4/SCAN_0001.jpg').load(function(e) { 
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) { 
    alert('foobar x.x'); 
} 
else { alert('image loaded yay \o/'); } }); 

回答

0

該溶液爲這是爲了除去對this.complete的條件檢查的typeof this.naturalWidth,和this.naturalWidth。這有點糟糕,因爲如果圖像無法加載,我們希望有某種退步。

prop.image.attr('src', 'http://localhost/uploads/239-4/SCAN_0001.jpg').load(function(e) { alert('image loaded yay \o/'); });