开发者

Javascript: How to calculate the exact position of the viewport?

开发者 https://www.devze.com 2022-12-31 21:53 出处:网络
My problem is I need to get the position of the viewport relative to the extent of the entire document.I am only concerned with Firefox.

My problem is I need to get the position of the viewport relative to the extent of the entire document. I am only concerned with Firefox.

My issue is that everything I have read says that:

viewport height is window.innerHeight
scroll position is window.pageYOffset
document total height is document.height

So, I would expect that if I scrolled开发者_JS百科 to the bottom of a page that

window.innerHeight + window.pageYOffset == document.height

But it doesn't! Can someone please explain to me why this is?


When scrolling all the way to the bottom, this thould return true

window.innerHeight + window.pageYOffset == document.documentElement.scrollHeight

Document.height can be misleading because it is sometimes set to 100% in the CSS, which messes it up.

0

精彩评论

暂无评论...
验证码 换一张
取 消