blob: fbfc6d5befd8d3c3bab9fe7bcf381c8b24a24d0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
---
title: Document.scrollingElement
slug: Web/API/Document/scrollingElement
translation_of: Web/API/Document/scrollingElement
---
<div>{{APIRef("DOM")}}</div>
<p><strong><code>scrollingElement</code></strong> ( {{domxref("Document")}} 的只读属性)返回滚动文档的 {{domxref("Element")}} 对象的引用。 在标准模式下, 这是文档的根元素, {{domxref("document.documentElement")}}.</p>
<p>当在怪异模式下, <code>scrollingElement</code> 属性返回 HTML <code>body</code> 元素(若不存在返回 null )。</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">var <var>element</var> = document.scrollingElement;</pre>
<h2 id="示例">示例</h2>
<pre class="brush: js">var scrollElm = document.scrollingElement;
scrollElm.scrollTop = 0;
</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('CSSOM View','#dom-document-scrollingelement','scrollingElement')}}</td>
<td>{{Spec2('CSSOM View')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
{{Compat("api.Document.scrollingElement")}}
|