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
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.
What about calling a java script function scrolling to a div id of the page holding the iframe? Is that possible?
How about using JSNI and scrolling in parent or top window? Something like this:
public static native void scrollToTop() /*-{ $wnd.parent.scrollTo(0,0); // or `$wnd.top.scrollTo(0,0); }-*/;
The combination with top should also work with just "window". The $wnd is just because GWT is actually running in an embedded iframe. But I'm not sure if your code will be allowed to scroll parent document if they come from different servers.
Scrolling with javascript
Most people hate iframes for a number of reasons though, you should avoid using them if at all possible.