Download File Using jQuery

I might suggest this, as a more gracefully degrading solution, using preventDefault:

$('a').click(function(e) {
    e.preventDefault();  //stop the browser from following
    window.location.href="https://stackoverflow.com/questions/1296085/uploads/file.doc";
});

<a href="no-script.html">Download now!</a>

Even if there’s no Javascript, at least this way the user will get some feedback.

Leave a Comment