-
File Downloads
First, my web skills are very limited, so be gentle.
If you got to AO Security downloads, and actually download something you get to the point where a page is displayed suggesting that if the download does not start automatically, click here ...
At the same time the download starts automatically.
How is that done. I can start a page automatically by redirecting in a pages headers, but the I can't display that message.
Any help appreciated.
Steve
-
The meta refresh seems to work fine for most sites that offer downloads this way:
Code:
<meta http-equiv="refresh" content="1; url=http://www.yoursite.com/downloads/file.zip">
Stick that in the <head> area of your HTML file (or generate it automatically using PHP, ASP etc.) and it should work.
You can also use JavaScript, something like this:
Code:
<body onLoad='window.location.href="http://www.yoursite.com/downloads/file.zip"'>
Obviously, the second version will only work if JavaScript is enabled, but most browsers do have it switched on. The first version will work in pretty much any browser.
The reason the above code snippets work is because browsers automatically recognise zip files etc. as being file types (or rather, MIME types) that can't be rendered by a browser and so they display a download box whilst leaving the original page in the background. This wouldn't work if you wanted to offer up a plain text file for download (the browser would simply load it in the window) unless you placed in a zip file or tar archive.
-
*look at the greenie that pwaring got for answering such a easy answer* :p
-
Quote:
Originally posted here by SDK
*look at the greenie that pwaring got for answering such a easy answer* :p
It's only easy if you know the answer. ;)
-
Quote:
Originally posted here by SDK
*look at the greenie that pwaring got for answering such a easy answer* :p
And the greenie didn't even come from me....
Until now.
Thanks pwaring - that's a huge help.
Steve