【发布时间】:2017-09-15 14:51:22
【问题描述】:
当尝试将anchor 标记的.click() 调用到auto click url 时。
该代码在除Internet Explorer v11 之外的所有浏览器中都能正常工作。
我们将不胜感激。
var strContent = "a,b,c\n1,2,3\n";
var HTML_APS = strContent;
var data = new Blob([HTML_APS]);
var temp_link = document.createElement('a');
temp_link.href = URL.createObjectURL(data);
temp_link.download = "report_html.htm";
temp_link.type = "text/html";
temp_link.style = "display:none";
document.body.appendChild(temp_link);
if (confirm("Press a button!") == true) {
temp_link.click();
temp_link.remove();
}
这里是fiddle。
【问题讨论】:
-
对于 IE,使用
navigator.msSaveOrOpenBlob- jsfiddle.net/hcqn9m5a/3 -
这里没有jQuery代码,为什么会有那个标签?
标签: javascript html internet-explorer