History.length是一个只读属性,返回当前session中的history个数,包含当前页面在内。举个例子,对于新开一个tab加载的页面当前属性返回值1。
语法
length = history.length;
例子
var result = window.history.length; // 返回当前session中的history个数
说明
说明 | 状态 | 注释 |
---|---|---|
HTML Living Standard History.length |
Living Standard | No change from HTML5. |
HTML5 History.length |
Recommendation | Initial definition. |
浏览器兼容性
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参考
- The
History
interface it belongs to.