So, in my application the user can export their work to excel.
It works by opening a popup window (window.open(...)
) which the parent then writes the data to a form, then posts the form back to the server.
The server generates the file, and streams it back down to the popup window where a download dialog appears. It also writes a cookie with a token.
This token, is unique to each download popup window, and when a window sees that cookie (Checking regularly) it closes itself with window.close()
as the user has received the file download prompt.
This works great in IE7 and IE8
However, because IE9 decided to get rid of the dialog and replace it with an infobar, the window closes before the user can take action to download, and if they do click it, they never know when it's done without opening the downloads dialog manually.
As a temporary solution, the popup is no longer closed.
However, I want to be able to close it for the user as once their download has started it's completely useless to them.
How can I close this window and still be able to alert the user in IE9 that their download is complete and can be opened?
Use an iframe - they work much better and you have more control. Simply set display: none;
I did something like that just a little while ago. My solution was to get rid of the window.open
and instead use Content-Disposition
to coerce the browser to download the document instead of opening it.
Change your server code to insert this HTTP header before generating the Excel document, and then change all download buttons/links to ordinary links like <a href="server/document">Download the report as Excel</a>
Content-Disposition: attachment; filename=someFilename.xls
EDIT: Sorry, I missed the part with the five minute rendering time.
You could still use Content-Disposition for this with just a dash of Javascript. Have the server report back when the document is generated. Then just close the window opened by window.open
, and have the main window load the document that has the Content-Disposition header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With