Open url in new mobile safari instance?: Window.open()

202 views
Skip to first unread message

markww

unread,
Dec 30, 2012, 1:57:50 PM12/30/12
to google-we...@googlegroups.com
Hi,

I have a Button, when clicked, I'd like to open a url in a new browser instance. The following works on desktop:

    Window.open(url, "_blank", null);

When I run the same code in a UIWebView on ios, nothing happens. Ideally I'd like to open a new instance of mobile safari directed to that url. Does anyone have any ideas of how to do this? I can fall back on catching the url in my objective-c code, but ideally there's something we could do directly in javascript to trigger mobile safari to open,

Thanks

Paul Stockley

unread,
Dec 30, 2012, 9:30:36 PM12/30/12
to google-we...@googlegroups.com
This works on iOS Fullscreen web applications. I think it may also work on a UIWebView

public void open(String url) {
Anchor a = new Anchor();
a.setTarget("_new");
a.setHref(url);
RootPanel.get().add(a);
NativeEvent e = Document.get().createHtmlEvent("click", true, true);
a.getElement().dispatchEvent(e);
RootPanel.get().remove(a);
}

Mark Wyszomierski

unread,
Dec 30, 2012, 11:04:50 PM12/30/12
to google-we...@googlegroups.com
Hi Paul,

Thanks for the sample - it loads the target in the UIWebView. I tried using a target of "_blank" as well, same result. I might have to just catch external urls in the native app and launch safari manually,

Thank you

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/UVzOE3n_CyQJ.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Jens

unread,
Dec 31, 2012, 10:35:24 AM12/31/12
to google-we...@googlegroups.com
You have to program that behavior into UiWebView, see:


-- J.
Reply all
Reply to author
Forward
0 new messages