Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to save the content of a html page to a file using Javascript?

Status
Not open for further replies.

lyphard

Programmer
Jan 14, 2004
9
CA
I found myself in a scenario where the user fills up a form and I need to save the entire form (i.e. not only the form fields but also the static texts and styles etc.) So I figured it's easier to save the entire html page. Can I do this in Javascript? Thanks.
 
u cannot do this entirely javascript, what u can do is get the innerHTML of the table thats holding the form, save it to a hidden field and submit the page to a server script that can save it to the database...

Known is handfull, Unknown is worldfull
 
I tried but the innerHTML property won't save the current state of the document. e.g. if I type "aaa" in an input field, the innerHTML property will return <input name="blah" ...> but no "value="aaa"" which is filled by the user. Is there a way to work this out? Thanks.
 
You could do this client-side in IE, using the FileSystemObject ActiveX control. This would not work in any other browser, however.

You could always use an email address (with the mailto protocol) as the form submission URL, and then either send the mail to someone (who can then save it), or copy / paste the text and save it that way.

Those aside, and aside from any copy / paste routines you might write in JS, there's not much else you can do without involving server-side techniques.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top