var doc = w.document;
doc.open('application/CSV','replace');
doc.charset = "utf-8";
doc.write("all,hello");
doc.close();
if(doc.execCommand("SaveAs",null,"file.csv")) {
window.alert("saved ");
}else {
window.alert("cannot be saved");
}
not working in IE 8
but woks in IE 6
what is the problem ? it is alerting “cannot be saved”
help me !!! advance thanks
The problem seems to be caused by an old bug that was fixed in Windows XP but is apparently unpatched in my Windows 7. From http://support.microsoft.com/kb/929863:
Sure enough, change the file extension to “.txt” and watch it magically work in IE8.
The only workaround that comes to mind is to have a server-side language create the CSV file, and serve it up as a download (using the
Content-disposition: attachmentheader).