我的目标是检查图像是否已成功加载。它在现代浏览器中运行良好,但 IE8 或 7 这是一个可怕的问题。这是一个示例代码:
var img = new Image(),
url = 'http://something.com/images/something.gif';
$(img).attr('src', url).load(function() {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
alert('broken image!');
}
else {
alert('successfully loaded');
}
}
任何人都知道解决这个问题吗?提前感谢!