JS 匯出txt文字
function dataToTxt(exportData) {
var w = window.open(“about:blank”, “匯出”, “height=0,width=0,toolbar=no,menubar=no,scrollbars=no,resizable=on,location=no,status=no”);
var dt = new Date();
//w.document.charset = “GB2312”;
w.document.write(exportData);
try {
w.document.charset = “GB2312”;
} catch (err) { }
w.document.execCommand(“SaveAs”, false, dt.getFullYear() “-” (dt.getMonth() 1) “-” dt.getDate() “-” dt.getTime() “.txt”);
w.close();
var dt = new Date();
//w.document.charset = “GB2312”;
w.document.write(exportData);
try {
w.document.charset = “GB2312”;
} catch (err) { }
w.document.execCommand(“SaveAs”, false, dt.getFullYear() “-” (dt.getMonth() 1) “-” dt.getDate() “-” dt.getTime() “.txt”);
w.close();
}
注:引數exportData為文字
写评论
很抱歉,必須登入網站才能發佈留言。