iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

September 7, 2008
Web Design Clinic - Art meets Webdesign
About
 
September 6, 2008
Browser safe colors - do we care?
About
 
September 6, 2008
Get a Daily CSS Tip
About
 
September 5, 2008
It's safe to use Google Chrome now
About
 
September 5, 2008
Add a comment
.net
 
September 5, 2008
The Partial Function Application in JavaScript
WebReference.com
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /JavaScript

Open the "SAVE AS" dialogue box directly from a link! 

  Views:    29719
  Votes:    13
by Romeo Marquez 12/10/03 Rating: 

Synopsis:

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!
Pages: 
The Article

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 

Pages: 



 
  Sponsors