如何检查网页页面是否滚动?

Muz*_*ain 9 jquery internet-explorer scroll mouse-position

有什么办法在javascript中检查网页是否已垂直滚动?专门用于Internet Explorer?我需要在IE中获取鼠标位置但是使用jQuery事件e.pageY它在页面未滚动时给出正确的值但是当页面向下滚动时它会给出错误的位置.

Nic*_*ver 42

如果任何未来的googlers发现这个,快速的例子是:

if(!$(window).scrollTop()) { //abuse 0 == false :)
  alert("You are at the top of this window");
}
Run Code Online (Sandbox Code Playgroud)

  • 或者没有 jQuery `if(window.pageYOffset == 0) {alert("窗口顶部");}` (3认同)

Pet*_*ric 3

如果您熟悉使用 jQuery,请查看这个问题:

如何在 jQuery 中确定窗口的高度和滚动位置?