aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/document/scrollingelement/index.html
blob: 9f6e68e342bb1131d9a6e68a6c4bd84cad59dd9f (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
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>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Edge</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome(44.0)}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoDesktop("48.0")}}<sup>[1]</sup></td>
   <td>{{CompatNo}}</td>
   <td>33.0</td>
   <td>9.0</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Edge</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>36</td>
   <td>9.0</td>
   <td>{{CompatChrome(44.0)}}</td>
  </tr>
 </tbody>
</table>
</div>

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