我需要生成一个csv,然后建议下载它。 它适用于除IE之外的所有浏览器
var csvContent = "data:text/csv;charset=utf-8,";
dataString = "name1,firstname1,addr1";
csvContent += dataString;
var encodedUri = 'data:application/csv;charset=utf-8,' +encodeURI(dataString);
window.open(encodedUri);
答案 0 :(得分:0)
这是一个有效的解决方案
if (navigator.appName == "Microsoft Internet Explorer") {
var oWin = window.open();
oWin.document.write('sep=,\r\n' + CSV);
oWin.document.close();
oWin.document.execCommand('SaveAs', true, fileName + ".csv");
oWin.close();
}