如何使用javascript在客户端创建HTML文件?

如何使用javascript在客户端创建HTML文件?

问题描述:

朋友们,您好!

如何使用javascript在客户端创建HTML文件?

document.documentElement.innerHTML的值表示客户端网页的全部内容,那么如何通过JS将document.documentElement.innerHTML值保存为HTML文件?

提前谢谢。

Hello, friends!
How can I create a HTML file on the client's side using javascript?
There is a value of document.documentElement.innerHTML that represents the whole content of the webpage on the client's side, so how can I save the document.documentElement.innerHTML value as a HTML file via JS?
Thank you in advance.

不确定这是不是你想要的但是试试这个:

https://github.com/eligrey/FileSaver.js [ ^ ]

这是一个演示:

http://eligrey.com/demos/FileSaver.js/ [ ^ ]
not sure if that's what you want but try this :
https://github.com/eligrey/FileSaver.js[^]
here's a demo :
http://eligrey.com/demos/FileSaver.js/[^]


您无法在客户端文件系统上创建文件,这将是一个巨大的安全风险。
You can't create files on the client file system, it would be a massive security risk.