document.scrollingElement属性返回文档的滚动元素。也就是说,当文档整体滚动时,到底是哪个元素在滚动。 标准模式下,这个属性返回的文档的根元素document.documentElement(即<html>)。兼容(quirk)模式下,返回的是<body>元素,如果该元素不存在,返回null。 // 页面滚动到浏览器顶部 document.scrollingElement.scrollTop = 0; 或者也可以像下面 document.documentElement.scrollTop = 0 document.body.scrollTop = 0; 获取可视区域距离页面顶部的距离 scrollTop = document.scrollingElement.scrollTop scrollTop=document.documentElement.scrollTop || document.body.scrollTop