我做了一些代码,这对所有浏览器都有效期待Edge ...
代码:
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./) || navigator.userAgent.indexOf('Edge')>-1) {
exportTable.document.open();
exportTable.document.write(exportData);
exportTable.document.close();
exportTable.focus();
sa = exportTable.document.execCommand("SaveAs",true,"exportData.xls");
}
else{
sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(exportData));
}
在Edge浏览器中: 我在这里遇到问题......
exportTable.document.open();
HTML:
</div>
<iframe id="exportTable" style="display:none"></iframe>
</div>
我也是这样想的:
var doc = exportTable.document;
doc.open();
doc.write(exportData);
....
但它没有成功..
Edge中“iframe.documenet.open()”的替代品是什么? 如何为所有浏览器提供支持。??
在chrome和firefox下载时,我无法控制'下载文件名'....
Note : I prepared that table manually by using javascript. I didnt use HTML for table preperation.. because i want to export some columns only based on the demand..