Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start automatic download of a file in Internet Explorer?

How do I initialize an automatic download of a file in Internet Explorer?

For example, in the download page, I want the download link to appear and a message: "If you download doesn't start automatically .... etc". The download should begin shortly after the page loads.

In Firefox this is easy, you just need to include a meta tag in the header, <meta http-equiv="Refresh" content="n;url"> where n is the number of seconds and url is the download URL. This does not work in Internet Explorer. How do I make this work in Internet Explorer browsers?

like image 368
Pop Catalin Avatar asked Oct 01 '08 08:10

Pop Catalin


People also ask

How do I enable automatic Downloads on Internet Explorer?

If the menu bar is hidden, press Alt to make it visible. In the Internet Options dialog box, from the Security tab, select the Internet zone, and then click Custom level.... Scroll down to "Downloads". Under "File download" (IE 9) or "Automatic prompting for file downloads" (IE 8 or 7), select Enable.

How do I make Internet Explorer 11 automatically download files?

File Download SettingsSelect Tools > Internet Options. Click the Security tab. Click Custom Level. About 1/3 of the way down the page, enable automatic prompting for file downloads and File download.


2 Answers

SourceForge uses an <iframe> element with the src="" attribute pointing to the file to download.

<iframe width="1" height="1" frameborder="0" src="[File location]"></iframe> 

(Side effect: no redirect, no JavaScript, original URL remains unchanged.)

like image 133
devio Avatar answered Oct 01 '22 22:10

devio


I hate when sites complicate download so much and use hacks instead of a good old link.

Dead simple version:

<a href="file.zip">Start automatic download!</a> 

It works! In every browser!


If you want to download a file that is usually displayed inline (such as an image) then HTML5 has a download attribute that forces download of the file. It also allows you to override filename (although there is a better way to do it):

<a href="report-generator.php" download="result.xls">Download</a> 

Version with a "thanks" page:

If you want to display "thanks" after download, then use:

<a href="file.zip"     onclick="if (event.button==0)       setTimeout(function(){document.body.innerHTML='thanks!'},500)">  Start automatic download! </a> 

Function in that setTimeout might be more advanced and e.g. download full page via AJAX (but don't navigate away from the page — don't touch window.location or activate other links).

The point is that link to download is real, can be copied, dragged, intercepted by download accelerators, gets :visited color, doesn't re-download if page is left open after browser restart, etc.

That's what I use for ImageOptim

like image 37
Kornel Avatar answered Oct 01 '22 23:10

Kornel