var image = new Image();
image.onLoad = function() {
alert("loaded");
}
image.onError = function() {
alert("not loaded");
};
image.src ="https://s3.amazonaws.com/profileImages.mySample.com/spiderman.png" //dummy URL for reference only.
这是我的代码。 我从亚马逊服务中获取图像,问题是如果我收到一些错误,如:
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>ABCDEFGHIJ</RequestId>
<HostId>
AABCDEFGHIJKLMNOPQRST
</HostId>
</Error>
然后我的代码没有执行image.onError()。
如何检查网址中是否存在图片?
答案 0 :(得分:0)
var image = new Image();
image.onload = function() {
alert("loaded");
}
image.onerror = function() {
alert("not loaded");
};
image.src ="https://s3.amazonaws.com/profileImages.mySample.com/spiderman.png";