开发者

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

开发者 https://www.devze.com 2023-01-26 14:06 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消