detecting when the "File download" popup is closed
No such event exists. You need to take a different approach to solve this.
- target the download link to a hidden iframe with a name (
target="myhiddeniframe"
) - on click of the download link, show your loading spinner
- set the
onload
attribute of the iframe to a callback that hides your spinner
Net effect: you "spin" while the pdf is generated, and "unspin" when the "File download" dialog appears (as opposed to when the "File download" dialog is closed).
I am very sure that the answer is no, unless you want to consider some sort of ActiveX plugin to the browser (in which case the answer might still be no...)
I had to work on this kind of issue, on another project. I finally found a smart solution, as explained in another Stackoverflow question.
The explanation is given in the following post: http://gruffcode.com/2010/10/28/detecting-the-file-download-dialog-in-the-browser
The idea is to "simply" use a cookie to define when the file is downloaded.
- open your waiting popup
- do an AJAX query to generate the file, which returns the URL to that file
- in the AJAX query callback, close your waiting popup then redirect to the file URL
Example:
$('.generate_file_asynchronously').click(function(){
var url = $(this).attr('href');
show_loading_message();
$.get(url, function(file_url) {
hide_loading_message();
window.location.href = file_url;
});
return false;
});