[英]Dynamically created Anchor tag click method not downloading file in internet explore 11
锚标记不在IE中下载文件,而是提供了在应用商店中搜索应用以打开文件的选项。 对于chrome和FF,此代码可以正常工作。 我不知道这是在Windows 7中发生还是没有发生,因为我正在使用Windows 8.1,Windows 7没有适用于应用程序的选项。
var a = document.createElement("a");
a.href = filepath;
a.download = filename;
a.click();
任何帮助将不胜感激。 谢谢。
直接从SOpost报价
Internet Explorer当前不支持A标签上的Download属性。
参见http://caniuse.com/download和http://status.modern.ie/adownloadattribute ; 后者表示该功能是IE12的“正在考虑中”。
这可能会有所帮助:
var blob = new Blob([response.responseText], { type: headers['content-type'] });
if (navigator.msSaveOrOpenBlob) {
//Launches the associated application for a File or Blob saving for non webkit based browser such as safari or IE
navigator.msSaveOrOpenBlob(blob, "cvSummary.xml");
}
else {
//code for webkit based browser
var link = document.createElement('a');
document.body.appendChild(link);
link.style = "display: none";
var url = window.URL.createObjectURL(blob);
link.href = window.URL.createObjectURL(blob);
link.download = "cvSummary.xml";
link.dataset.downloadurl = ["text/xml", link.download, link.href].join(':');
link.click();
window.URL.revokeObjectURL(url);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.