Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kiinlam/2bac193a3fd62e141ff01f2ae1e79dda to your computer and use it in GitHub Desktop.
Save kiinlam/2bac193a3fd62e141ff01f2ae1e79dda to your computer and use it in GitHub Desktop.
document.documentElement和document.body的区别
// 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;
@kiinlam
Copy link
Author

kiinlam commented Mar 29, 2018

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment