[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to call File DownLoad Window of the browser?

Posted on 2000-01-02
3
Medium Priority
?
247 Views
Last Modified: 2006-11-17
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..)
0
Comment
Question by:kulsmadya
3 Comments
 
LVL 6

Accepted Solution

by:
tecbuilder earned 60 total points
ID: 2319584
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
 

Expert Comment

by:cath
ID: 2338621
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
 

Expert Comment

by:KMWorld
ID: 7930938
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

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question