如何使用文件的URL下载IE 10或IE 11中的文件并使用它? [英] How can I download a file in IE 10 or IE 11 using URL of the file and using it?

查看:206
本文介绍了如何使用文件的URL下载IE 10或IE 11中的文件并使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此部分代码对Opera,Mozilla,Chrome表现相当不错,但在任何版本的IE中都无法正常执行

This part of code performs quite well for Opera, Mozilla, Chrome, but it cannot perform appropriately in any version of IE

var link = document.createElement("a");
       link.setAttribute("id", id here);
       
       link.setAttribute("href", URL here);
       var NameToDownload = desired name here;
       link.setAttribute("download", NameToDownload);
       link.innerHTML = NameToDownload;





如果我知道它的URL,如何通过IE从服务器下载文件?

提前谢谢。



How can a file be downloaded via IE from the server if I know its URL?
Thank you in advance.

推荐答案

正如您所发现的,Internet Explorer不支持下载属性:

http://caniuse.com/#feat=download [ ^ ]

https://status.modern.ie/adownloadattribute [ ^ ]



唯一的解决方法似乎是使用服务器端代码来指定 Content-Disposition 标题 [ ^ ],值设置为附件
As you've discovered, Internet Explorer doesn't support the download attribute:
http://caniuse.com/#feat=download[^]
https://status.modern.ie/adownloadattribute[^]

The only workaround appears to be to use server-side code to specify the Content-Disposition header[^], with the value set to attachment.


嗯,实际上我是什么找到。像这样的定义表现良好。它仅以IE 10和11的适当方式执行.I

Hmmm, what actually I have found. Such a definition like this one performs well. It performs in an appropriate way only with IE 10 and 11. I
var link = document.createElement("a");
       link.setAttribute("id", id here);

       link.setAttribute("href", URL here);
       var NameToDownload = desired name here;
       
       link.innerHTML = NameToDownload;



但是如果您希望下载txt,则会看到文件已打开但未保存。

它应该以某种方式走来走去......


But if you prefer to have txt downloaded you'll see the file opened but not saved.
It should be somehow walked around...


这篇关于如何使用文件的URL下载IE 10或IE 11中的文件并使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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