Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: how to create a "save as" button?

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

like image 734
His Avatar asked May 17 '10 13:05

His


People also ask

How do I add a Save button in HTML?

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to make a button. Step 2: Now, move the cursor at that place where we want to show the button on the web page. And then, type the Html <button> tag at that point.

How can create button option in HTML?

Definition and UsageThe <button> tag defines a clickable button. Inside a <button> element you can put text (and tags like <i> , <b> , <strong> , <br> , <img> , etc.). That is not possible with a button created with the <input> element!

How do you link a button to a file in HTML?

In HTML, a button link to another page can be by using the <a> tag, <input> tag, and the <form> tag. A link on a button is get by href=”” attribute of <a> tag. The “type=button” and “onclick=link” attributes are used to create a link on the button.


2 Answers

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.

like image 96
Alex K. Avatar answered Oct 16 '22 21:10

Alex K.


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 :)

like image 43
Sarfraz Avatar answered Oct 16 '22 21:10

Sarfraz