admin管理员组文章数量:1314239
Hi I'm uploading a file through an iframe.
HTML:
<from action="upload.php" target="iframe">
<input type="file" name="file" />
<input type="submit" />
</form>
<iframe name="iframe" src="javascript:false;"></iframe>
Now I would like to abort the upload while uploading. So I would like to stop the iframe loading.
What I've tried
$("iframe").attr("src", "javascript:false;");
$("iframe").remove();
if (typeof(window.frames[0].stop) === "function")
window.frames[0].stop();
else
window.frames[0].document.execCommand("Stop");
All functions don't throw an error but after a while the file I've canceled was displayed in the upload folder. So that's the weird thing.
Any suggestions?
Hi I'm uploading a file through an iframe.
HTML:
<from action="upload.php" target="iframe">
<input type="file" name="file" />
<input type="submit" />
</form>
<iframe name="iframe" src="javascript:false;"></iframe>
Now I would like to abort the upload while uploading. So I would like to stop the iframe loading.
What I've tried
$("iframe").attr("src", "javascript:false;");
$("iframe").remove();
if (typeof(window.frames[0].stop) === "function")
window.frames[0].stop();
else
window.frames[0].document.execCommand("Stop");
All functions don't throw an error but after a while the file I've canceled was displayed in the upload folder. So that's the weird thing.
Any suggestions?
Share Improve this question asked Mar 12, 2012 at 14:36 noobnoob 9,2124 gold badges39 silver badges65 bronze badges 1-
window.stop
cancels any further resource loading but not the original request: developer.mozilla/en-US/docs/Web/API/Window/stop – Jānis Elmeris Commented Jul 5, 2023 at 11:23
2 Answers
Reset to default 9While you can destory the iframe
element, any HTTP requests it has made cannot be cancelled. This is by design of HTTP.
The closest analogy is that it's like trying to stop a bullet you've fired by destroying the gun.
Try flash uploaders. They have many advantages against standard uploading input, like multiple file upload, stopping upload queue, file size limit etc. Try a demo here: http://www.uploadify./demos/. Of course they have a bit plicated implementation.
本文标签: javascriptHow to stop iframe loadingStack Overflow
版权声明:本文标题:javascript - How to stop iframe loading? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741963637a2407424.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论