一段使用javascript保存文件的代码。这里方法可以保存指定id元素下的所有html内容;不过这个方法只支持IE浏览器。
function createHtml() { try { save_record("index1", $("#yhtcprediv").html()); } catch (e) { alert(e); } } function save_record(filename, content) { //打开新窗口保存 var winRecord = www.sychzs.cn('about:blank', '_blank', 'top=500'); www.sychzs.cn("text/html", "utf-8"); winRecord.document.write(" " + content + ""); winRecord.document.execCommand("SaveAs", true, filename + ".html"); winRecord.close(); }
简单好用的JS保存文本文件到本地
保存文本文件到本地 ')}(this); siteToolbar(); 保存
总结