Scrolling a page to the top from an iframe (containing a gwt application)

前端 未结 4 2066
北恋
北恋 2021-01-25 23:42

There is a website which has an iframe including a web application. Let\'s assume that the application has a height of 1000px. At the bottom of the application (1000px) there is

4条回答
  •  不知归路
    2021-01-26 00:06

    Finally I found the solution. Set at the top of your iframe an anchor and call it with:

    public static native void scrollToTop()  /*-{
    
        $wnd.location.href = '#anchorName';
    
    }-*/;
    

    This will also force the parent window (the window holding the iframe) to scroll to that anchor.

提交回复
热议问题