History.length是一个只读属性,返回一个整型,表示在session中元素的个数,包括当前已经加载的页面。例如,在新的标签里面加载的页面,此时的属性是1

 

语法

length = history.length;

 示例

var result = window.history.length; // Returns the size of the history of the current session.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'History.length' in that specification.
Living Standard No change from HTML5.
HTML5
The definition of 'History.length' in that specification.
Recommendation Initial definition.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit) Mozilla Servo
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes) implemented
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

See also

  • The History interface it belongs to.

Document Tags and Contributors

 Contributors to this page: chinazhaghai, erikadoyle, ea1000, fscholz, kscarfone, teoli
 Last updated by: chinazhaghai,