views:

71

answers:

1

We have a popup window where the user makes some selections and clicks on a button to generate a pdf file. We show a progress display (animated gif), and then eventually send the pdf contents to the user with content-disposition: inline. The user then usually prints the pdf file.

For some users, there is no inline browser viewer for pdf files, and the user is prompted to save the pdf file. In these cases, the progress display remains open, even after the file has been delivered. What is a good way of detecting that the user chose to save the file, rather than have it display inline?

The one idea that I've come up with so far is to set a timer in the popup window to close the window if its contents are still around. In theory, the timer would be cleared if the contents of the window were replaced by the pdf viewer. Are there other options? How do I know how long to set the timer for, if the pdf generation could possibly take a long time? Can I send just the http headers first, and the pdf contents later to trigger the pdf viewer quickly?

A: 

We solved this by setting a timer just before we ask the server to start generating the PDF. If the PDF is opened by the viewer in the browser window, the timer is cancelled. If the timer is not cancelled, then it closes the window. We chose a long time for the timer.

Bernard Chen