此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Document.scrollingElement

基线 广泛可用

自 2016年8月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

scrollingElementDocument 的只读属性)返回滚动文档的 Element 对象的引用。在标准模式下,这是文档的根元素, document.documentElement

当在怪异模式下,scrollingElement 属性返回 HTML body 元素(若不存在返回 null)。

语法

var element = document.scrollingElement;

示例

js
var scrollElm = document.scrollingElement;
scrollElm.scrollTop = 0;

规范

规范
CSSOM View Module
# dom-document-scrollingelement

浏览器兼容性