I'm working on a GWT application, which should behave in a slightly different manne开发者_运维知识库r 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?
Wrap a bit of javascript into JSNI:
public static native boolean isFrame() /*-{
return ($wnd!=$wnd.top);
}-*/;
I haven't tested this but looking at the javadoc you can try something like:
RootPanel.getBodyElement().getParentElement().getTagName()
and see if it's an iframe or whatever tag you need
精彩评论