How do I get the height of the page on scroll?

Is it possible to determine how much the user has scrolled the page and determine the position of length that it covered.

I have tried:

var scroll=$wnd.scrollTop  

in JavaScript but it is giving result undefined?

Am I doing it wrong?

有帮助吗?

解决方案

Try it using GWT JSNI.

public static native int getScrollTop()
/*-{
    return $wnd.pageYOffset;
}-*/;

For more info have a look at window size and scrollbar position

其他提示

I used the next code to get the current scroll position of the webpage:

var y = $(document).scrollTop();

It worked for me.
(I hope that's what you were looking for)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top