0

I am trying to write a javascript which allows user to save file in csv format. I am able to this partially with save as option as text with below code: var w = window.frames.w;

w = document.createElement("iframe");
w.id = "w";
w.style.display = "none";
document.body.insertBefore(w);
w = window.frames.w;
w = window.open("", "_temp", "width=100,height=100");
var d = w.document;
d.open("text/plain","replace");
d.charset = "utf-8";
d.write(content);
d.close();
var name = "batchExport_ash.txt";
d.execCommand("SaveAs", null, name)

Please can anyone guide me here. Many thanks.

FelixTheCode
  • 54
  • 1
  • 6
  • Does this previous SO question help? http://stackoverflow.com/questions/21012580/is-it-possible-to-write-data-to-file-using-only-javascript – Weather Vane Nov 02 '14 at 18:16
  • I afraid from above link i am not able to achieve the solution. I believe that its has to do with : d.open("text/plain","replace"); Would be helpful that i check what are different option of opening. Will see related opening mode for csv. – FelixTheCode Nov 02 '14 at 18:48
  • And what about this page? http://4umi.com/web/javascript/filewrite.php – Weather Vane Nov 02 '14 at 19:43

0 Answers0