--- title: History.length slug: Web/API/History/length translation_of: Web/API/History/length ---
History.length是一个只读属性,返回当前session中的history个数,包含当前页面在内。举个例子,对于新开一个tab加载的页面当前属性返回值1。
length = history.length;
var result = window.history.length; // 返回当前session中的history个数
说明 | 状态 | 注释 |
---|---|---|
{{SpecName('HTML WHATWG', "history.html#dom-history-length", "History.length")}} | {{Spec2('HTML WHATWG')}} | No change from {{SpecName("HTML5 W3C")}}. |
{{SpecName('HTML5 W3C', "browsers.html#dom-history-length", "History.length")}} | {{Spec2('HTML5 W3C')}} | Initial definition. |
{{Compat("api.History.length")}}