GWT open page in a new tab GWT open page in a new tab google-chrome google-chrome

GWT open page in a new tab


I used this code and it works for me in google chrome and mozilla firefox 3.6.8 browsersIf you want to open a page in new window you should write code as

Window.open("www.google.com","_blank","enabled");

If you want to open a page in new tab you should write code as

Window.open("www.google.com","_blank","");


I am not sure you are going to be able to control this the way you want. The problem is that browsers can decide when to open windows and when to open tabs. For example, firefox has the option: "Open new windows in new tabs instead". And don't forget the browsers that don't support tabs (yes, those do still exist).

Since this is such a problematic aspect of the user experience, my recommendation would be to reconsider your design. Is it really that important for you application to differentiate between opening a new tab and opening a new window?


This code works for me:

  1. Before calling the Async method keep a reference to a new window with empty parameters.
  2. At onSuccess() method set the URL of the window.

Button someButton = new Button("test");SelectionListener<ButtonEvent> listener = new SelectionListener<ButtonEvent>() {    public void componentSelected(ButtonEvent ce)    {        final JavaScriptObject window = newWindow("", "", "");        someService.doSomething(new AsyncCallback()         {           public void onSuccess(Object o)            {                setWindowTarget(window, "http://www.google.com/");           }        });                }}someButton.addSelectionListener(listener);private static native JavaScriptObject newWindow(String url, String name, String features)/*-{    var window = $wnd.open(url, name, features);    return window;}-*/;private static native void setWindowTarget(JavaScriptObject window, String target)/*-{    window.location = target;}-*/;

Found at: http://groups.google.com/group/google-web-toolkit/browse_thread/thread/574b3b828271ba17