Document.scrollingElement

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

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

语法

var element = document.scrollingElement;

示例

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

规范

Specification Status Comment
CSS Object Model (CSSOM) View Module
scrollingElement
Working Draft Initial definition

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 44.0 (Yes) 48.0 (48.0)[1] 未实现 33.0 9.0
  
Feature Android Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support 未实现 (Yes) ? ? 未实现 36 9.0 44.0

[1] This feature was initially implemented in Gecko 47.0 (Firefox 47.0 / Thunderbird 47.0 / SeaMonkey 2.44) behind the preference dom.document.scrollingElement.enabled, defaulting to true on Nightly builds and false otherwise. In Gecko 48.0 (Firefox 48.0 / Thunderbird 48.0 / SeaMonkey 2.45) the feature got enabled by default and the preference removed.

文档标签和贡献者

此页面的贡献者: nDos
最后编辑者: nDos,