取消活动的图像请求。

4

可能是重复问题:
Javascript:取消/停止图像请求

如何中止仍在进行中的图像请求?

示例:

var img = new Image();
var img.src = "http://www.google.co.in/images/nav_logo29.png";
window.setTimeout(function(){
     //Code to abort/cancel image request if it hasn't triggered onload or onerror even after 20 seconds of sending request.
},20000)

我猜这就是你想要的。https://dev59.com/P3E85IYBdhLWcg3wXCS1 - naveen
2个回答

1
在Firefox中,将图像的src设置为空字符串将会中止任何活动请求。

0

一旦浏览器发送了图片请求,就无法“取消”它。

在这种情况下,您可以做的最多的是隐藏图像元素或显示友好的消息。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接