How I can save rendered html page using javascript.
-
You can use command line JavaScript to automate IE and save whatever you want... but I suspect that you trying to do it from the page - than see Oded's reply.Alexei Levenkov– Alexei Levenkov2011-09-17 07:16:41 +00:00Commented Sep 17, 2011 at 7:16
-
Where do you want to save the HTML to?andy– andy2011-09-17 07:17:51 +00:00Commented Sep 17, 2011 at 7:17
5 Answers
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.
2 Comments
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.
Comments
On what purpose? If you just want to print the page, use document.print instead.
1 Comment
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. :(