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
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.
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!
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.
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.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With