【发布时间】:2011-07-13 22:39:28
【问题描述】:
是否可以取消使用隐藏 iframe 的文件上传?
我尝试将 iframe 的来源设置为空字符串,但上传没有被中断。
【问题讨论】:
标签: ajax iframe file-upload upload
是否可以取消使用隐藏 iframe 的文件上传?
我尝试将 iframe 的来源设置为空字符串,但上传没有被中断。
【问题讨论】:
标签: ajax iframe file-upload upload
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
【讨论】:
当前将 iframe src 设置为“javascript:false”对我有用。
【讨论】:
我不确定,但我想从 dom 中删除 iframe 就足够了?
【讨论】:
试试这个:
iframe.contentWindow.stop(); //for anything but IE
iframe.contentWindow.document.execCommand("Stop"); // for IE
【讨论】: