Dagosi
Dagosi

Reputation: 948

How to close a window in GWT?

I have the next code to close a GWT window, but It doesn't work, could you tell me what's wrong or how to close a GWT window?. Thanks in advance:

public native void closeBrowser()
/*-{
    $wnd.close();
}-*/;

public void onModuleLoad() {

    Button cerrar = new Button("Cerrar");
    cerrar.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {

            Window.alert("Voy a cerrar");
            closeBrowser();
        } 
    });

    RootPanel.get().add(cerrar);
}

Upvotes: 4

Views: 7346

Answers (1)

okrasz
okrasz

Reputation: 3976

Script is not allowed to close window that wasn't opened by script.

Here is an article which says how to workaround it: http://csharpdotnetfreak.blogspot.com/2008/11/javascript-windowclose-does-not-work-in.html

Upvotes: 3

Related Questions