Abort Image Request

























































































































































OS

Browser

“”

null

remove

delete

stop

StopImage

Stop

Button

Timeout

Windows

IE6,7,8

√(e)

√(e)

II

×

×

×

×

×

21s (e)

FF4,5

II

II

II

×

II

×

×

II

21s (e)

Chrome12

×

×

×

×

II

×

×

II

21s (e)

Safari4,5

×

×

×

×

II

×

×

II

21s (e)

Opera9

×

√(e)

×

×

II

×

×

II

47s (e)

Opera11

II

√(e)

II

II

II

×

×

II

47s (e)

Mac OS X

Safari5

×

×

×

×

II

×

×

II

1.2m (e)

Chrome12

×

×

×

×

II

×

×

II

1.2m (e)

FF4,5

II

II

II

×

II

×

×

II

1m’15s (e)

Ubuntu

FF4,5

II

II

II

×

II

×

×

 

3m’9s (e)

Chrom(e/ium)12

×

×

×

×

II

×

×

 

3.2m (e)



  • Windows XP, Server 2003, 7.


  • Mac OS X 10.6.7


  • Ubuntu 11.04


标题注解:


“”img.src = “”nullimg.src = nullrevmoveimg.removeAttribute(“src”)deletedelete img[“src”]stopwindow.stop()StopImagedocument.execCommand(“StopImage”)Stopdocument.execCommand(“Stop”)ButtonBrowser Stop Button.


图标注解:


√能够 Abort 图片请求,并回调 (e)onerror/(a)onabort/(l)onload 函数。II能够 Abort 图片请求,但不触发任何事件进行回调。≈部分版本支持。如 Stop/StopImage 在 .NET Framework 3.0 中取消了支持。×不能 Abort 图片请求,或不支持该方法。


事件回调




var img = new Image();
img.onload = function(){out.innerHTML += “loaded.”;};
img.onabort = function(){out.innerHTML += “aborted.”;};
img.onerror = function(){out.innerHTML += “errored.”;};
window.setTimeout(function(){
out.innerHTML += “before.”;
// abort.
img.src = null;
out.innerHTML += “after.” + img.complete;
}, 2000);





测试结果:


IEbefore.errored.after.Operabefore.after.errored.FFbefore.after.Chromebefore.after.Safaribefore.after.


See Also




转自:http://blog.hotoo.me/abort-image-request.html