document.body与document.documentElement

document.body 获取的是body,document.documentElement获取的是html,在任何浏览器上都是如此

相关问题:

1.获取页面滚动条滚动距离

chrome,safari上用document.body.scrollTop,document.documentElement.scrollTop恒为0

firefox,IE上用document.documentElement.scrollTop,document.body,scrollTop恒为0

2.document.documentElement.offsetHeight在非IE浏览器上都是获取html的实际高度,而在IE上是可看见的部分区域的高度!

原文地址:https://www.cnblogs.com/yanze/p/6049991.html