Did you ever wanted to provide a way to save the content of a dynamically generated page to the hard disk?
Here's how you can do it!
I first got the need for a “SAVE AS dialogue box” from a Real State portal I was developing (http://www.ExpoQuieroCasa.com).
My client wanted to provide the users with a way to Save to the Hard Disk every result from a search.
Either to have a button or a link or an image that the user could press and have the dialogue box pop-up!
I wasn’t sure if it could be done so I had to do some research.
At the MSDN Library I found the execCommand Method which executes a command on the current document.
One of the many parameters of this method is the SaveAs Command which saves the current Web page to a local file.
The SaveAs Command has the following format:
document.execCommand('SaveAs','1','Name of the webpage.htm');
Here’s an example using the SaveAs command with a link
<a href='#' onclick="javascript: document.execCommand('SaveAs','1','Cool Example');">Save this article to your HD!</a>
When we click the link, the SAVE HTML DOCUMENT dialogue box will
appear with “Cool Example” as the default name.
There are other methods that can allow you to either to copy, cut, paste,
undo, select, unselect, etc.
For more info on these methods please go to:
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/execcommand.asp
This easy trick will make your site different by providing a direct way
to save the content of your webpages!
Questions?
Write me, Romeo Marquez Guzman romeo@gelattina.com
www.gelattina.com