Java – scroll to the top of the page in a GWT application
•
Java
I have a GWT application and I want to use this method to scroll to the top of the page:
public static native void scrollTop() /*-{ $wnd.scroll(0,0); }-*/;
The method is invoked in the onClick method of TreeNodeListenerAdapter:
new TreeNodeListenerAdapter() { @Override public void onClick(Node node,EventObject e) { scrollTop(); } }
It doesn't work. I don't know why When I put an alert in my method:
$wnd.alert("Treenode clicked");
I saw the alarm, but the page didn't scroll What did I miss here?
Solution
If you want to scroll to the top of the page, just do the following:
Window.scrollTo (0,0);
Please make sure you are importing the correct package com google. gwt. user. client. Window
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码