How to cancel an image load after a period of time?

后端 未结 3 1330
余生分开走
余生分开走 2020-12-09 23:13

I need to be able to cancel an image load after a set period of time, and it needs to subsequently call the onError action.

What it will do:

Attempt to retr

3条回答
  •  一生所求
    2020-12-09 23:49

    Use window.stop to stop download

     if(window.stop !== undefined)
     {
        window.stop();
     }
     else if(document.execCommand !== undefined)
     {
     document.execCommand("Stop", false);
     }
    

    To change image source

     var img = document.getElementBYId("yourImageID");
     img.setAttribute("src","newSource.gif");
    

提交回复
热议问题