将页面从iframe滚动到顶部(包含gwt应用程序) [英] Scrolling a page to the top from an iframe (containing a gwt application)
问题描述
我的目标是现在当有人按下该按钮时,浏览器应该将其页面滚动到顶部(这意味着滚动发生在iframe之外。是否有人知道如何在gwt中执行此操作的解决方案(不需要在页面持有iframe)?
很多thx提前!
最后,我找到了解决方案,在iframe的顶部设置一个锚点并将其调用:
public static native void scrollToTop ()/ * - {
$ wnd.location.href ='#anchorName';
} - * /;
这也会强制父窗口(持有iframe的窗口)滚动到该锚。
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 button. If the user presses the button, then the application changes its view and the new length is only 20px (the rage 20px to 1000px is therefore just white (blank page) ).
My goal is now that when someone presses on that button then the browser should scroll its page to the top (meaning that the scrolling happens outside the iframe. Does anyone know a solution how to do that in gwt (without setting an anchor in the page holding the iframe)?
Many thx in advance!
解决方案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.
这篇关于将页面从iframe滚动到顶部(包含gwt应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!