Solution!  On the application's HTML page, instead of creating the
<iframe> with id="__gwt_downloadFrame", use a <div>, like so:

<body>
        <!-- For the DownloadIFrame widget. -->
        <div id="__gwt_downloadFrame"></div>

        <!-- For the rest of my application loads here. -->
        <div id="__gwt_myappp"></div>
</body>

Also, in the download servlet, set the content disposition to
attachment, like so:

        response.setContentType("text/csv; header=present");
        response.addHeader( "Content-disposition", "attachment; filename=" +
                URLEncoder.encode(filename, "UTF-8") + ".csv" );

If the content disposition is set to "inline", Safari will (in the
case above) see text file that it can open in the hidden IFRAME.  (Per
RFC2183, "The display of an attachment is generally construed to
require positive action on the part of the recipient, while inline
message components are displayed automatically when the message is
viewed.")

I have tested this in Firefox 3, IE 7, and Safari 3 and 4.  Your
mileage may vary.

On May 31, 1:42 pm, Thad <[email protected]> wrote:
> In my application I want users to be able to download a file from the
> server (via a servlet), but **not** require them to enable pop-ups, as
> they do if I use
>
>         native void openURLInNewWindow(String url) /*-{
>                 $wnd.open(url);
>         }-*/;
>
> I tried this class.  It works under Firefox, but not with IE or
> Safari:
>
> public class DownloadIFrame extends Frame
> implements LoadHandler, HasLoadHandlers {
>
>         public DownloadIFrame(String url) {
>                 super();
>                 setSize("0px", "0px");
>                 setVisible(false);
>                 addLoadHandler(this);
>                 RootPanel.get("__gwt_downloadFrame").add(this);
>                 setUrl(url);
>         }
>
>         public HandlerRegistration addLoadHandler(LoadHandler handler) {
>                 return addHandler(handler, LoadEvent.getType());
>         }
>
>         public void onLoad(LoadEvent event) {
>         }
>
> }
>
> On my application's HTML page, I have
>
> <iframe src="javascript:''" id="__gwt_downloadFrame" tabIndex='-1'
> style="position:absolute;width:0;height:0;border:0"></iframe>
>
> My application is loaded into a separate <div>
>
> Any ideas how to make this work in IE and Safari?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to