Created
March 29, 2018 08:37
-
-
Save kiinlam/2bac193a3fd62e141ff01f2ae1e79dda to your computer and use it in GitHub Desktop.
document.documentElement和document.body的区别
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scrollHeight 内容完整高度 | |
scrollHeight = document.compatMode === "CSS1Compat" ? document.documentElement.scrollHeight : document.body.scrollHeight; | |
// or | |
scrollHeight = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight); | |
// scrollTop 滚动高度 | |
scrollTop = document.documentElement.scrollTop || document.body.scrollTop; | |
// clientHeight 可视高度 | |
clientHeight = document.compatMode === "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight; |
Author
kiinlam
commented
Mar 29, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment