Search code examples
javagwtgwt2

How to determine whether my GWT app is running inside a frame/iframe or not?


I'm working on a GWT application, which should behave in a slightly different manner when it is running inside a frame and when running directly in a browser window. The question is: how to determine at runtime whether we're in a frame or in a window?


Solution

  • Wrap a bit of javascript into JSNI:

    public static native boolean isFrame() /*-{
        return ($wnd!=$wnd.top);
    }-*/;