Javascript 中止活动映像请求

Javascript 中止活动映像请求,javascript,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

可能重复:

如何中止仍在运行中的映像请求

例如:

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)

一旦浏览器发送了对图像的请求,您就不能“取消”它


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

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

>我想这就是您想要的。