0

I am opening a new window in a gwt widget with the help of window.open(url, "", ""); Once new window has opened i am doing some editing operation. I want to make some code to be executed in the gwt widget once the user closes the newly opened window. Here(in gwt widget) how can know that the window is closed or not? I think we have some window events, but i do not know how to use them.

M.S.Naidu
  • 2,239
  • 5
  • 32
  • 56

3 Answers3

1

I figured out how to be notified when child window closes. In gwt we can do it by using JSNI.
Below method is a jsni to get the reference of the newly opened window.

private static native BodyElement getNewWindowRef(String url) /*-{
    var childWindow = window.open(url, "_blank", "height=800px width=300px location=no");
    return childWindow;
}-*/;

To tell whether the window is closed or not, we can use following jsni code, passing the variable received from the above.

private static native boolean getNewWindowStatus(BodyElement childWin) /*-{
    var ret = false;

    if (childWin.closed) {
       ret = true;
    } 

    return ret;
}-*/;
pythonian29033
  • 5,148
  • 5
  • 31
  • 56
M.S.Naidu
  • 2,239
  • 5
  • 32
  • 56
0

After reading ths post:

GWT - "Access is Denied" JavaScript error when setting document.domain in Internet Explorer only

Might this be a possibilit to send a mesage to another browser window.

Community
  • 1
  • 1
El Hoss
  • 3,767
  • 2
  • 18
  • 24
  • Yes i have seen these window handlers in the gwt documentation, i do not know how the above code will execute which will be put in gwt widget once i closed the window. – M.S.Naidu Jan 09 '14 at 13:49
0

You can't do it with GWT, since Window.open() returns no reference to the opened window.

Your best bet is to try and imitate this answer using a native function. No guarantees it will work. Here's another javascript answer regarding the same issue.

Here's what Window.open() does by default:

  public static native void open(String url, String name, String features) /*-{
    $wnd.open(url, name, features);
  }-*/;
Community
  • 1
  • 1
Churro
  • 4,166
  • 3
  • 25
  • 26