0

How I can save rendered html page using javascript.

2
  • 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. Commented Sep 17, 2011 at 7:16
  • Where do you want to save the HTML to? Commented Sep 17, 2011 at 7:17

5 Answers 5

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

@user949976 - To do what task? You say save a rendered HTML file, but you don't say where it was rendered and where you want to save it. From the question, I don't see what ASP.NET has anything to do with it.
I have save image. On clicking that button I want to give popup which will ask user to save the html page to local drive.
2
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.

Comments

1

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

0

On what purpose? If you just want to print the page, use document.print instead.

1 Comment

I have image with href. On click event of which I want to show popup which will save the rendered html page.
0

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. :(

2 Comments

:(? I'd say :-D and the "phew!". It would be awful if you could do this!
yes, "phew" would be the right thing to say. I was frowning because I couldn't give a complete answer. + if you think about it, as one technology progresses, it pushes all the others to do so to, so if js had even more power, don't consider only the bad parts, think of the benefits too!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.