<script language=javascript>
function Save(){
var txt = document.all.output.value;
b = window.open();
b.document.open();
b.document.write(txt);
b.document.close();
b.document.execCommand('saveas',true,'output.html');
b.window.close();
}
</script>
<center>仅保存文本框中部分:</center>
<table width="90%" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>不保存</td>
<td><input type="button" value="Save" class="trans" onclick="Save()">
<textarea rows="20" cols="50" id="output" class="txtedit"></textarea>
</td>
</tr>
</table>
用js保存页面指定内容、指定文件类型
最新推荐文章于 2024-06-24 18:43:19 发布
本文介绍了一种使用 JavaScript 实现的简单文本内容导出方法。通过调用浏览器的 saveas 功能,可以将文本区域的内容快速保存为 HTML 文件。这种方法适用于简单的文本数据导出场景。
3527

被折叠的 条评论
为什么被折叠?



