views:

987

answers:

3

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 displayed (because the generation of the PDF can be long), and once the file is created, IE displays the "File download" popup that proposes "Open", "Save" and "Cancel" options.

Is there a way in Javascript to know from my web page when this popup is closed, i.e. when the user has saved (or opened) the PDF file?

To be a little more precise, in the web page that displays the link to the PDF file, a modal popup is displayed (the "waiting popup") in order to make the user waits for the "File download" popup. The problem is that when the user Saves (or open) the PDF file, the "File download" popup closes, but the user then "returns" to the original webpage, with the waiting popup still displayed.

Note that my application runs only in IE6, so I am not against a IE(6)-only solution...

I have also no problem with solutions that need jQuery ;)

Edit: If a solution exists to catch any event that is fired exactly when the "File download" popup is displayed to the user (i.e. before the user chooses to Save, Open or Cancel), it will be fine for me too!

+1  A: 

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...)

Richard Ev
+2  A: 

No such event exists. You need to take a different approach to solve this.

  1. target the download link to a hidden iframe with a name (target="myhiddeniframe")
  2. on click of the download link, show your loading spinner
  3. 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).

Crescent Fresh
Exactly what I was looking for. I already had the modal dialog with the iframe, but I was trying to bind an event to the document load of the loading page in the iframe... this did not work. You solution works. Thanks!
aquillin
A: 

Hi,

Is the Answer 2 work?

I am having the same problem. i tried the solution 2. but the approach not working for me.

could you send me the sample code.

Vijayaraja