How to call File DownLoad Window of the browser?

I want to call the file download window of the browser(IE & Netscape) to download txt, jpg & gif files (these type of files r displayed in the browser instead of download when i gave the href..)
kulsmadyaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tecbuilderCommented:
The quick answer is you can't.  These are built in functions of the browser.  What you should do is include instructions as to how people can get the text file and images.  A text file (.txt) can be displayed in a browser window.  If people want to save the file, all they need to do is click on the menu File | Save As (Netscape and MSIE).  For images, people need to right click on the image and select Save Image As (Netscape) or Save Picture As (MSIE).

tec
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cathCommented:
for the path to the document do

file://pathtodocument

or try zipping the file for download.

basically if the browser can't display the type of file if brings up the 'save as' dialogue box. If it can display it, it does.

so that if you want to bring up the 'save as' dialogoe for a pdf file, instead of displaying it in the browser window, zip it so that the extension is .zip (and not .pdf), and put a bit of text by the link telling the user they will need to unzip it after download (winzip is so ubiquitous this isn't usually a problem).

Cath
0
KMWorldCommented:
The following should work in IE 5.0+, although I haven't tested with Netsacpe / Opera yet.

(1) In your HTML file, add the following Javascript:

  function callSaveAs() {
    if (document.execCommand) {
      document.execCommand("SaveAs");
        location = 'listGenerateRecurrentPayment2.html';
      }
    } else {
      alert('SaveAs Function Not Supported by Browser');
    }
  }

(2) In the desired location (a Form Button, a HREF link, etc.), add this Javascript action to it:

  onclick='javascript:callSaveAs();

That should do it.

KMWorld
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.