Save html page of using javascript
How I can save ren开发者_C百科dered html page using javascript.
You can't. Javascript in the browser has no file IO capabilites.
If it had, going to any website could write anything to your hard drive.
var everything = document.all
will give you everything, but then you still need to move off the browser into a localfile. You will need a serverside language for that.
At least I do know of a Windows/IE-specific way to save the current HTML file:
http://p2p.wrox.com/javascript-how/3193-how-do-you-save-html-page-your-local-hd.html#post78192
However, I wonder if other browsers (i.e. Chrome) have some similar file I/O API. Obviously, according to previous answers, there's no universal standard.
On what purpose? If you just want to print the page, use document.print
instead.
you can get all of the page contents and then you can
- send an ajax request to a script that handles the html content (be aware of cross domain restrictions)
- save the contents into a cookie
- save the contents into localStorage or some local db
There is no reliable way to do this in js. :(
精彩评论