[英]Javascript: How to calculate the exact position of the viewport?
我的问题是我需要获取视口相对于整个文档范围的位置。 我只关心Firefox。
我的问题是,我阅读的所有内容都表示:
viewport height is window.innerHeight
scroll position is window.pageYOffset
document total height is document.height
因此,我希望如果滚动到页面底部,
window.innerHeight + window.pageYOffset == document.height
但事实并非如此! 有人可以向我解释为什么吗?
一直滚动到底部时,此方法应返回true
window.innerHeight + window.pageYOffset == document.documentElement.scrollHeight
Document.height可能会引起误解,因为CSS中有时将它设置为100%,这很混乱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.