9

In your browser, when you want to save an HTML page that you are currently viewing, you normally go to the File menu and click Save As.

Can I have a little button at the bottom of an HTML page that does the same thing? So instead of going to the File menu -> Save As, I want my user to be able to click the button to save the page on to the disk.

There is a solution exists using Javascript as far as I know, but it only works for IE. See here: link text

apaderno
  • 28,547
  • 16
  • 75
  • 90
His
  • 5,891
  • 15
  • 61
  • 82

4 Answers4

8

You could have the link run a server side script that loads the HTML file and writes it back to the client with a Content-Disposition: attachment; filename=xxx.html header.

Alex K.
  • 171,639
  • 30
  • 264
  • 288
3

The document.execCommand('SavaAs') works only in IE but the following link suggests other possibilities you may want to try out.

Here is the answer to that :)

Community
  • 1
  • 1
Sarfraz
  • 377,238
  • 77
  • 533
  • 578
2

Take a look at downloadify jQuery plugin, which using flash to save. Javascript alone is impossible.

YOU
  • 120,166
  • 34
  • 186
  • 219
0

You have to create a button that downloads the HTML file, or the page you're on:

<form><input type="button" value="Download Now" onClick="window.location.href='yourpage.html'"></form>
Jamal
  • 763
  • 7
  • 22
  • 32