[英]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.