开发者

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

开发者 https://www.devze.com 2023-02-16 04:16 出处:网络
Is it possible to cancel file upload that uses hidden iframe? I\'ve tried to set source of iframe to emp开发者_如何学Pythonty string, but upload haven\'t been interrupted.the iframe is the transport

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

I've tried to set source of iframe to emp开发者_如何学Pythonty string, but upload haven't been interrupted.


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


Try this:

iframe.contentWindow.stop(); //for anything but IE
iframe.contentWindow.document.execCommand("Stop"); // for IE


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消