Is there any possibility of performing a javascript action after the end of a download?

Asked

Viewed 315 times

4

I have a link to a PDF on my site. I would like the page to enable another button at the end of your download.

But the question is: this is possible only with javascript/jquery?

If yes, how would it work?

  • I only see the option to download by AJAX, your action can be executed after successful completion of the request, that answer shows how to download. Downside: not all browser versions support this solution

  • See this [answer](http://http://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download "Title"), can help you...

1 answer

4


Uses the jquery plugin named fileDownload, example usage:

//
//With jquery.fileDownload.js
//custom use with promises
//
$(document).on("click", "a.fileDownloadPromise", function () {
    $.fileDownload($(this).prop('href'))
        .done(function () { alert('File download a success!'); })
        .fail(function () { alert('File download failed!'); });

    return false; //this is critical to stop the click event which will trigger a normal file download
});

Downtown here = https://github.com/johnculviner/jquery.fileDownload

Example working here = http://jqueryfiledownload.apphb.com/

  • that cool the plugin lol did not know

Browser other questions tagged

You are not signed in. Login or sign up in order to post.