javascript - 使用 javascript 编译 html 并将其转储到文件

标签 javascript html

我有 html 和 javascript 代码,可以修改 html 并打印数据, 我想将此页面转储到文件中。

<html>
<head>
<script type="text/javascript">
document.write("<h1>This is a heading one </h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>
</head>
<body>
<h1>This is a heading two </h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>

输出.html

<html>
<head>
<script type="text/javascript">
document.write("<h1>This is a heading one </h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>
</head>
<body>
<h1>This is a heading one </h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<h1>This is a heading two </h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>

我想我需要像 html+ java 脚本引擎这样的东西..带有命令行界面的浏览器,这样我就可以调用一个页面,然后将其输出转储到文件.. 任何想法??...任何帮助将不胜感激,谢谢

最佳答案

如果您只想手动执行几次,您可以使用 IE 9 Dev 工具。在 IE 9 中,您可以按 F12,然后按 Ctrl+S 将文件保存到所需位置。

关于javascript - 使用 javascript 编译 html 并将其转储到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9646337/

相关文章:

html - 引导边界问题

javascript - 按日期对对象数组进行排序

javascript - 范围过滤器错误

javascript - Vue.js,v-bind 上多个类的选项

javascript - 叠加的 div 之间的间距,不影响宽度

html - 页脚文本的定位

javascript - Ace 编辑器,如何删除除一个之外的所有 keyBindings?

javascript - 如何将新用户添加到 db.json

javascript - Ionic - 默认选中 2 个单选按钮(不同的列表)

javascript - 如何获取子 ng-repeat 内父作用域数组/ng-repeat 的索引