如何取消/停止在IE浏览器中上传文件 [英] How can I cancel/stop uploading of a file in IE javascript

查看:410
本文介绍了如何取消/停止在IE浏览器中上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两种表单的页面。其中一个不可见,包含 input type =file。我正在使用隐藏表单上传文件(表单的目标是iframe元素)。我的问题是如何在IE下使用javascript停止/取消上传文件。我试图用JQuery删除隐藏的表单,文件仍在上传。

I have a page with two forms. One of them is not visible and contains input type="file". I am uploading file with the hidden form(target of the form is an iframe element). My question is how to stop/cancel uploading of the file with javascript under IE. I have tried to remove the hidden form with JQuery and the file is still uploading.

提前致谢。

推荐答案

感谢您的回复。
据我调试那个案例,我得到了以下结果:) - 无法取消上传。上述方法取消了页面以接收响应,文件正在上传到服务器端。
以下是我原型的标记:

Thanks for the replies. As far as I debugged that case I got the following result :) - it is not possible to cancel upload. The methods above cancelled the page to receive the response and the file is uploading to the server side. Here is the mark up of my prototype:

<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>

<input type="button" id="button1" value="stopUpload" onclick="stopUpload()"/>
   <script type="text/javascript">

        function stopUpload() {               
            var frame = $get("iframe1");
            frame.contentWindow.document.execCommand("Stop");                
        }

    </script>
</div>
</form>
<form id="form2" enctype="multipart/form-data" action="http://localhost/TestingSite/Default.aspx"
method="POST" target="iframe1">
<input type="submit" />
<input type="file" name="FileUploadTest" id="FileUploadTest"/>
</form>
<iframe id="iframe1" name="iframe1" width="500px" height="500px" ></iframe>

这篇关于如何取消/停止在IE浏览器中上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆