Javascript – IE7 issue – cannot download streamed file when Automatic prompting for file downloads is disabled

internet-explorer-7javascriptjsp

My application is J2EE (JSP/Servlet) based. I encounter an issue when i try to open a new window (pop-up) from JSP and call a Servlet action (e.g. Streamer.do) which streams a PDF file inside that pop-up.

Problem:
While IE 7 -> Tools -> Internet Options -> Security -> Custom Level -> Downloads -> Automatic prompting for file downloads is Disabled and while pop-up window get opened, I am unable to download the file (Save/Open prompt is not comming up).

In contrast, when I enable this option, I am able to download. But this option sometimes would be disabled in some environments.

While testing this in Mozilla Firefox 3.0/3/5/IE6 it is working fine without any settings change. When i check it to enable i then get the Save/Open prompt to work correctly.

This should be problem with IE7. Can anybody help us with Javascript or any working settings which doesnt care whether the "Automatic prompting for downloads" option in IE7 is enabled.

Any help in this would be much appreciated.

Regards!

Jai

Best Answer

The setting that you mention is designed to prevent automatic downloading of files and that is exactly what you are trying to do. If you want downloads to work even if this option is selected, you must download a file as a direct result of user action.

User clicks on a link that leads to a downloaded file -> works correctly.

User clicks on a button, that in javascript redirects to a downloaded file -> works correctly.

User clicks on a button, that in javascript opens a popup, and that popup requests a file -> this fails.

User clicks on a button, that in javascript delays execution of redirecting to a downloaded file -> this fails.

Same thing with popups and popup blockers. Direct action is permitted, indirect action is not.