如何关闭GWT中的窗口?

时间:2021-03-19 17:04:55

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:

我有下一个关闭GWT窗口的代码,但它不起作用,你能告诉我什么是错的或者如何关闭GWT窗口吗?提前致谢:

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);
}

1 个解决方案

#1


3  

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

这是一篇文章,说明如何解决它:http://csharpdotnetfreak.blogspot.com/2008/11/javascript-windowclose-does-not-work-in.html

#1


3  

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

这是一篇文章,说明如何解决它:http://csharpdotnetfreak.blogspot.com/2008/11/javascript-windowclose-does-not-work-in.html