How to check if webpage page is scrolled? [duplica

2019-06-16 08:55发布

This question already has an answer here:

Is there any way in javascript to check if web page has been vertically scrolled? specially for Internet Explorer? I need to get the mouse position in IE but using jQuery event e.pageY it gives correct value when page is not scrolled but when page is scrolled down then it gives wrong position.

2条回答
Lonely孤独者°
2楼-- · 2019-06-16 09:51

In case any future googlers find this, the quick example is:

if(!$(window).scrollTop()) { //abuse 0 == false :)
  alert("You are at the top of this window");
}
查看更多
干净又极端
3楼-- · 2019-06-16 09:55

Check out this question if you are comfortable with using jQuery:

How do I determine height and scrolling position of window in jQuery?

查看更多
登录 后发表回答