views:

157

answers:

1

Hello everybody,

I'm getting an anoying problem in IE6.02 when trying to download a file through flex + struts action, the browser opens a new window and doesn't close it after the download has finished.

The flex code is:

navigateToURL(url,"_blank");

The content headers are:

HTTP/1.x 200 OK Date: Thu, 29 Oct 2009 22:00:44 GMT Transfer-Encoding: chunked Content-Type: application-download; charset=UTF-8 Content-Disposition: attachment; filename=myfile.pdf X-Powered-By: Servlet/2.4 JSP/2.0

also, we tried with

Content-Type: application/pdf; charset=UTF-8

How do I close the new opened window automatically? In FF works perfectly.

Thanks in advance,

+1  A: 

Calling navigateToURL with *blank opens a new window (unless the browser's popup blocker blocks it) but doesn't return a reference to the newly opened window. So we cannot close it programmatically. Closing such automatically opened download windows once the download is complete is up to the browser. Have you considered using the Flash's inbuilt FileReference class to download files? It wouldn't open a new window - all it does is to prompt user to choose a place to save the file. Check the link for an example.

Amarghosh