--- title: Document.scrollingElement slug: Web/API/Document/scrollingElement translation_of: Web/API/Document/scrollingElement ---
{{APIRef("DOM")}}

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

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

语法

var element = document.scrollingElement;

示例

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

规范

Specification Status Comment
{{SpecName('CSSOM View','#dom-document-scrollingelement','scrollingElement')}} {{Spec2('CSSOM View')}} Initial definition

浏览器兼容性

{{CompatibilityTable}}

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatChrome(44.0)}} {{CompatVersionUnknown}} {{CompatGeckoDesktop("48.0")}}[1] {{CompatNo}} 33.0 9.0
Feature Android Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatNo}} 36 9.0 {{CompatChrome(44.0)}}

[1] This feature was initially implemented in Gecko 47.0 {{geckoRelease("47.0")}} behind the preference dom.document.scrollingElement.enabled, defaulting to true on Nightly builds and false otherwise. In Gecko 48.0 {{geckoRelease("48.0")}} the feature got enabled by default and the preference removed.