Presumably, you want the download dialog to appear immediately, then disappear and be replaced by a new page when rendering a new page?
Three ideas come to mind.
If you have control over the original page, but not for the purpose, use the click event handler to replace the normal behavior of tags with something like this:
- Show boot animation
- Leave an AJAX request to the URL indicated by the tag href attribute (alternately create the hidden URL as the source)
- When the request is complete, replace the contents of the document with the answer.
This can get really hairy since you will not lose the javascript and css defined on the original page. It also does not change the URL displayed in the user browser.
If you control the target and can make the target cache (even for a few seconds): you can load the page in the background via AJAX, and then redirect to it. The first load will be slow, then the redirect will load the page from the cache.
And another alternative: if you control the landing page, you can define an optional parameter, so if this parameter is present, the server returns a page consisting only of the loading animation and the javascript bit that the actual page loads.
source share