Is it possible to cancel file upload that uses hid

2019-02-12 16:43发布

Is it possible to cancel file upload that uses hidden iframe?

I've tried to set source of iframe to empty string, but upload haven't been interrupted.

4条回答
Anthone
2楼-- · 2019-02-12 17:11

Currenty setting iframe src to "javascript:false" works for me.

查看更多
劳资没心,怎么记你
3楼-- · 2019-02-12 17:17

the iframe is the transport channel that is carrying the form posting, so Atanas is correct, you have to stop the transport inside the iframe.

here is a way of doing it depending on browser:

if (iframeObj.contentWindow.document.execCommand)
    { // IE browsers
        iframeObj.contentWindow.document.execCommand('Stop');
    }
else
    { // other browsers
        iframeObj.contentWindow.stop();
    }
// notify user upload was cancelled, remove spinner images, etc
查看更多
Deceive 欺骗
4楼-- · 2019-02-12 17:17

Try this:

iframe.contentWindow.stop(); //for anything but IE
iframe.contentWindow.document.execCommand("Stop"); // for IE
查看更多
劫难
5楼-- · 2019-02-12 17:17

I'm not sure but i guess removing the iframe from the dom should be enough?

查看更多
登录 后发表回答