aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/document/height/index.html
blob: 8ace6753ec4fbf67bb80556f2365912c34f9e254 (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
---
title: Document.height
slug: Web/API/Document/height
translation_of: Web/API/Document/height
---
<div>{{APIRef("DOM")}} {{Obsolete_header}}</div>

<p> </p>

<div class="note">
<p><strong>Note:</strong> 在Gecko的6.0版本之后, <code>document.height</code> 不再被支持。 使用 <code>document.body.clientHeight来代替</code>. 详见 {{domxref("element.clientHeight")}}.</p>
</div>

<p>返回 {{domxref("document")}} 对象的高度. 在大多数场景中, 它相当于当前文档的 {{HTMLElement("body")}} 元素。</p>

<h2 id="Syntax" name="Syntax">语法</h2>

<pre class="syntaxbox notranslate"><var>pixels</var> = document.height
</pre>

<h2 id="示例">示例</h2>

<pre class="brush: js notranslate">// alert document height
alert(document.height);
</pre>

<h2 id="可选操作">可选操作</h2>

<pre class="syntaxbox notranslate">document.body.clientHeight
document.documentElement.clientHeight
document.documentElement.scrollHeight
</pre>

<h2 id="规范">规范</h2>

<p>HTML5</p>

<h2 id="兼容性">兼容性</h2>



<p>{{Compat("api.Document.height")}}</p>

<h2 id="另请参阅">另请参阅</h2>

<ul>
 <li>{{domxref("document.width")}}</li>
 <li>{{domxref("Element.clientHeight")}}</li>
 <li>{{domxref("Element.scrollHeight")}}</li>
</ul>