Similar to HTML anchor link - href and onclick both? post, mine is:
Download link
Forget about the href
and just do it all in the click function. You can navigate to another page after the update is complete. Here is my JQuery suggestion:
HTML
<a id="download" href="/tmp/download.mp3">Download link</a>
JavaScript (with JQuery)
$("#download").click(function(e){
e.preventDefault();//this will prevent the link trying to navigate to another page
var href = $(this).attr("href");//get the href so we can navigate later
//do the update
//when update has finished, navigate to the other page
window.location = href;
});
NOTE: I added in an id
for the a
tag to ensure it can be selected accurately via JQuery