How to determine if vertical scroll bar has reached the bottom of the web page?

后端 未结 6 2028
清酒与你
清酒与你 2020-12-09 05:31

The same question is answered in jQUery but I\'m looking for solution without jQuery. How do you know the scroll bar has reached bottom of a page

I would like to kno

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 06:26

    I just read through the jQuery source code, and it looks like you'll need the "pageYOffset". Then you can get the window height and document height.

    Something like this:

    var yLeftToGo = document.height - (window.pageYOffset + window.innerHeight);

    If yLeftToGo is 0, then you're at the bottom. At least that's the general idea.

提交回复
热议问题