How to start automatic file upload in Internet Explorer?

How to initialize automatic file download in Internet Explorer?

For example, on the download page, I want the download link to appear, and the message: "If the download does not start automatically ... etc.". Download will begin shortly after the page loads.

In Firefox, it’s easy, you just need to include the 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 to make this work in Internet Explorer browsers?

+65
javascript html internet-explorer meta-tags
01 Oct '08 at 8:19
source share
17 answers

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

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

(Side effect: No redirects, no JavaScript, the original URL remains unchanged.)

+100
01 Oct '08 at 8:34
source share

I hate it when sites complicate loading so much and use hacks instead of the good old link .

Dead simple version:

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

It is working! In every browser!




If you want to download a file that is usually displayed inline (for example, an image), then HTML5 has a download attribute that forces the file to be downloaded. It also allows you to override the file name ( although there is a better way to do this ):

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

Version with Thanks Page:

If you want to display "thank you" after downloading, use:

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

The function in this setTimeout may be more advanced and, for example, load the full page via AJAX (but do not leave the page - do not touch window.location and do not activate other links).

The fact is that the download link is real, you can copy, drag, intercept it with the help of download accelerators, get :visited color, do not reload if the page remains open after restarting the browser, etc.

Here is what I use for ImageOptim

+48
Nov 18 '08 at 23:16
source share

I had a similar problem and none of the above solutions worked for me. Here is my attempt (jquery required):

 $(function() { $('a[data-auto-download]').each(function(){ var $this = $(this); setTimeout(function() { window.location = $this.attr('href'); }, 2000); }); }); 

Usage: just add an attribute called data-auto-download to the link pointing to the download of interest:

 <p>The download should start shortly. If it doesn't, click <a data-auto-download href="/your/file/url">here</a>.</p> 

It should work in all cases.

+21
Mar 07 2018-12-12T00:
source share

I recently solved this by posting the following script on the page.

 setTimeout(function () { window.location = 'my download url'; }, 5000) 

I agree that the meta update will be nicer, but if it does not work, what are you doing ...

+20
Oct 01 '08 at 8:29
source share

A simple jQuery bit solved this problem for me.

 $(function() { $(window).bind('load', function() { $("div.downloadProject").delay(1500).append('<iframe width="0" height="0" frameborder="0" src="[YOUR FILE SRC]"></iframe>'); }); }); 

In my HTML, I just

 <div class="downloadProject"></div> 

All you have to do is wait a second and a half, and then add a div with an iframe related to the file you want to load. When the iframe refreshes on the page, your browser downloads the file. Just like that .: D

+7
Jun 25 2018-11-11T00:
source share

I used this, it seems to work and just JS, no frame:

 Your file should start downloading in a few seconds. If downloading doesn't start automatically <a id="downloadLink" href="[link to your file]">click here to get your file</a>. <script> var downloadTimeout = setTimeout(function () { window.location = document.getElementById('downloadLink').href; }, 2000); </script> 

NOTE: this starts a timeout at the time the page loads.

+5
04 Oct
source share

This is what I use on some sites (jQuery required) .:

 $(document).ready(function() { var downloadUrl = "your_file_url"; setTimeout("window.location.assign('" + downloadUrl + "');", 1000); }); 

The file loads automatically after 1 second.

+5
Jan 28 '13 at 15:40
source share

Works on Chrome, firefox and IE8 and above:

 var link = document.createElement('a'); document.body.appendChild(link); link.href = url; link.click(); 
+5
Apr 28 '16 at 13:48
source share

I checked and found that it will work when a button is clicked by writing the onclick event to the Anchor tag or enter button

 onclick='javascript:setTimeout(window.location=[File location], 1000);' 
+3
Jun 16 2018-12-12T00:
source share

Be sure to file the file without a header without a cache! IE has problems with this if the user tries to "open" the download without saving in the first place.

+2
03 Oct '08 at 18:11
source share

Back to the roots, I use this:

 <meta http-equiv="refresh" content="0; url=YOURFILEURL"/> 

Maybe not WC3, but it works fine on all browsers, without HTML5 / JQUERY / Javascript.

Greetings to Tom :)

+2
Jan 14 '16 at
source share

It seemed to work for me - in all browsers.

  <script type="text/javascript"> window.onload = function(){ document.location = 'somefile.zip'; } </script> 
+1
Jul 02 '10 at 11:30
source share

I think this will work for you. But visitors are easy if they got something in seconds without spending more time, and so they will visit your site again. <a href="file.zip" onclick="if (event.button==0) setTimeout(function(){document.body.innerHTML='thanks!'},500)"> Start automatic download! </a>

+1
Jan 07 '12 at 8:01
source share

For those who are trying to start a download using a dynamic link , it's hard to make it work consistently in browsers.

I had problems downloading PDF in IE10 + and the @dandavis' download function was used ( https://github.com/rndme/download ).

IE10 + needs msSaveBlob .

+1
Jul 07 '15 at
source share

Hope this will work with all browsers. You can also set the automatic download time.

 <html> <head> <title>Start Auto Download file</title> <script src="http://code.jquery.com/jquery-3.2.1.min.js"></script> <script> $(function() { $('a[data-auto-download]').each(function(){ var $this = $(this); setTimeout(function() { window.location = $this.attr('href'); }, 2000); }); }); </script> </head> <body> <div class="wrapper"> <p>The download should start shortly. If it doesn't, click <a data-auto-download href="auto-download.zip">here</a>.</p> </div> </body> </html> 

Demo here

+1
Aug 01 '17 at 6:43 on
source share

Good jquery solution:

 jQuery('a.auto-start').get(0).click(); 

You can even set a different file name to load inside the <a> tag:

 Your download should start shortly. If not - you can use <a href="/attachments-31-3d4c8970.zip" download="attachments-31.zip" class="download auto-start">direct link</a>. 
0
Feb 19 '19 at 6:11
source share

Another one:

 var a = document.createElement('a'); a.setAttribute('href', dataUri); a.setAttribute('download', filename); var aj = $(a); aj.appendTo('body'); aj[0].click(); aj.remove(); 
0
Apr 15 '19 at 9:18
source share



All Articles