Excel 导出文件在IE 11中不起作用
我正在尝试导出一个Excel文件,到目前为止,它确实适用于除IE 11之外的浏览器。以下是我的代码:Excel 导出文件在IE 11中不起作用,excel,internet-explorer,export,Excel,Internet Explorer,Export,我正在尝试导出一个Excel文件,到目前为止,它确实适用于除IE 11之外的浏览器。以下是我的代码: if (navigator.appName == "Microsoft Internet Explorer") { myFrame.document.open("text/html", "replace"); myFrame.document.write(data); myFrame.document.close(); myFra
if (navigator.appName == "Microsoft Internet Explorer") {
myFrame.document.open("text/html", "replace");
myFrame.document.write(data);
myFrame.document.close();
myFrame.focus();
myFrame.document.execCommand('SaveAs', true, fileName);
} else {
var blobdata = new Blob(data], { type: 'data:application/vnd.ms-excel' });
var link = document.createElement("a");
link.setAttribute("href", window.URL.createObjectURL(blobdata));
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
}
IE 11中没有错误消息,只是什么也没发生。它适用于IE<11
谢谢,我认为navigator.appname不是您想要的, 发件人: 返回的值因浏览器而异: IE11、Firefox、Chrome和Safari返回“Netscape” IE 10和早期版本返回“Microsoft Internet Explorer” 歌剧回归“歌剧”
您可以考虑使用Navigal.UsAgent
并确保正确解析字符串。谢谢,我这样做太粗心了