I have a web page (made with JSF) where some links allow the user to get a PDF file.
When the user clicks on such a link, a waiting popup (it is a modal panel) is di
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.
All of the answers that I read here and in related question on stackoverflow and elsewhere only solve the first part of the problem, the time it takes for the server to prepare the file. The second part of the problem, which is the time it takes for the file to actually finish downloading on the client, is not so trivial.
In our application we followed the following approach. We already have a notification push mechanism based on cometd (you can read more about cometd here: What is Cometd ? Why it is used and how to work on that), but I suppose you could also use WebSockets or something similar. We use Java in the back-end, but it can be anything. So:
No such event exists. You need to take a different approach to solve this.
target="myhiddeniframe"
)onload
attribute of the iframe to a callback that hides your spinnerNet 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...)
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;
});