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?
I hope this will works all the browsers. You can also set the auto download timing.
Demo Here
I used this, seems working and is just simple JS, no framework:
NOTE: this starts the timeout in the moment the page is loaded.
A simple bit of jQuery solved this problem for me.
In my HTML, I simply have
All this does is wait a second and a half, then append the div with the iframe referring to the file that you want to download. When the iframe is updated onto the page, your browser downloads the file. Simple as that. :D
I checked and found, it will work on button click via writing onclick event to Anchor tag or Input button
Back to the roots, i use this:
Maybe not WC3 conform but works perfect on all browsers, no HTML5/JQUERY/Javascript.
Greetings Tom :)
I hate when sites complicate download so much and use hacks instead of a good old link.
Dead simple version:
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):Version with a "thanks" page:
If you want to display "thanks" after download, then use:
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 touchwindow.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