View Full Version : To get download functionality

04-30-2008, 08:35 AM
I have to create a download link in java script.when i click on that link,it should give open, save,cancel buttons so that i can save one zip file in the path specified for the link.
Please help me in this regard.

04-30-2008, 02:07 PM
Just create or modify the link using document.write(), innerHTML, and/or the DOM. Make sure the href for the link is your intended .zip file, and that the onclick event (if any - none is required - will return true). The user's browser will control what happens, but 99.99% will pop an open/save dialogue for anything with a .zip extension.

The best method to use is generally the DOM, but that would depend upon the rest of the code, and your level of knowledge of javascript.

Also, depending upon how secure and accessible this must be, a method other than javascript might be better - something on the server side.

Unless the file to be downloaded needs to be able to change, no javascript is required:

<a href="whatever_path/whatever.zip">Whatever</a>

will do fine.

05-02-2008, 05:07 AM
Thanks so much John.
I am doing from Xml Dom itself.I just gave the path of my zip file to the link.it is working