PDA

View Full Version : How to save an HTML page by using javascripts


xingyu
09-16-2005, 04:02 PM
Dear Fellows:

An HTML page has been populated at the client side. I want a user be able to save all of its contents on the client machine. I know that this action can be done by clicking the IE menu File/Save As. However, I would like my user to click a button on the HTML page to call a javascript function, which save the contents of the dispalyed HTML page as a local HTML file. The problem is, what is the javascirpt codes.

Thanks for help;

XY

RysChwith
09-16-2005, 04:23 PM
It can't be done in precisely that fashion. The only thing you could do would be to save the data in cookies, which the page (they'd still have to access it on your server) would load the next time they visited. JavaScript does not have any file writing capabilities otherwise.

Rys

xingyu
09-16-2005, 04:38 PM
Thank you very much

Kakoo
01-26-2006, 09:22 AM
Hello,
I have the same needs.
Is there any possibility (maybe using other things than javascript) to save a page with a button on the HTML page ?
For information, my pages are generated by a cgi script in tcl.

Moreover it would be wondefull if there were a mean to precise the initial dir to save the page.

Thanks a lot for future answers.

Kakoo
01-27-2006, 11:11 AM
I just found an easy solution on another forum.
For information it is putting this in body:

<input name="Save" type="button" value="Save" onClick="javascript:document.execCommand('SaveAs','true','c:\\myHtmlDirectory\\myHtmlSavedPage.htm')">

coothead
01-27-2006, 12:20 PM
Hi there Kakoo,
I just found an easy solution...
Easy it may be, but bear in mind that it will only work in IE. :loopy:

Kakoo
01-27-2006, 01:54 PM
Yes i know :(.
But maybe i will find a way of doing this in firefox too.
I'm already happy to have found this.