Cancel active image requests

Possible duplicate:
Javascript: Cancel / stop image requests

How to abort an image request that is still on the fly?

Example:

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) 
+4
source share
2 answers

In Firefox, setting the src image to an empty string cancels any active request.

+1
source

Once the browser sends a request for a captured image, you cannot cancel it.

In most cases, you can hide the image element in this case or show a friendly message.

0
source

Source: https://habr.com/ru/post/1332995/


All Articles