aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/history/length/index.html
blob: bb713e6cb84549a3b985f97adac972b807776f9a (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
---
title: History.length
slug: Web/API/History/length
translation_of: Web/API/History/length
---
<div>{{ APIRef("HTML DOM") }}</div>

<p>History.length是一个只读属性,返回当前session中的history个数,包含当前页面在内。举个例子,对于新开一个tab加载的页面当前属性返回值1。</p>

<p> </p>

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

<p> </p>

<pre class="syntaxbox"><em>length</em> = <em>history</em>.length;
</pre>

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

<pre class="brush: js">var result = window.history.length; // 返回当前session中的history个数</pre>

<h2 id="说明">说明</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">说明</th>
   <th scope="col">状态</th>
   <th scope="col">注释</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', "history.html#dom-history-length", "History.length")}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>No change from {{SpecName("HTML5 W3C")}}.</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', "browsers.html#dom-history-length", "History.length")}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("api.History.length")}}</p>

<h2 id="参考">参考</h2>

<ul>
 <li>The {{domxref("History")}} interface it belongs to.</li>
</ul>