JavaScript: Forwarding to another page after downloading
If you have a link to download a file (e.g. a piece of software), you may want to redirect to another page after the user clicks the link, perhaps to gather download statistics or display a message to the user. Setting the window.location in an onclick event for that link does not work, as the opening “download” dialog seems to cancel that action.
Instead use a delay:
<script type=”text/javascript”>
function RedirectAfterDownload()
{
window.location = “http://google.com”;
}function OnDownloadClick()
{
// redirects after 1 second
setTimeout(‘RedirectAfterDownload()’, 1000);
}</script>
Then to use: <a href=”myfile.exe” onclick=”OnDownloadClick();”>Download File!</a>