【问题标题】:Is it possible to cancel file upload that uses hidden iframe?是否可以取消使用隐藏 iframe 的文件上传?
【发布时间】:2011-07-13 22:39:28
【问题描述】:

是否可以取消使用隐藏 iframe 的文件上传?

我尝试将 iframe 的来源设置为空字符串,但上传没有被中断。

【问题讨论】:

    标签: ajax iframe file-upload upload


    【解决方案1】:

    iframe 是承载表单发布的传输通道,所以 Atanas 是正确的,你必须停止 iframe 内部的传输。

    这是一种取决于浏览器的方法:

    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
    

    【讨论】:

      【解决方案2】:

      当前将 iframe src 设置为“javascript:false”对我有用。

      【讨论】:

        【解决方案3】:

        我不确定,但我想从 dom 中删除 iframe 就足够了?

        【讨论】:

          【解决方案4】:

          试试这个:

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

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2012-07-07
            • 1970-01-01
            • 2011-04-09
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多