Javascript Save CSV file in IE 8/IE 9 without using window.open()

感情迁移 提交于 2019-12-12 20:18:40

问题


I need to download a csv file using javascript in IE 8 and IE9.I tried using window.open().

Here is my code:

var URI = 'data:text/csv;charset=utf-8,';
var fileName = "text.csv";

var testlink = window.open("about:blank", "_blank");

testlink.document.write(fileData); //fileData has contents for the file

testlink.document.close();

testlink.document.execCommand('SaveAs', false, fileName);

testlink.close();     

This opens a new window and prompts to save the file.After saving the file,it returns back to the page.Instead of opening a blank page,I need to download the file by staying in the page

来源:https://stackoverflow.com/questions/27305191/javascript-save-csv-file-in-ie-8-ie-9-without-using-window-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!