History.length
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
History.length 是一个只读属性,返回当前 session 中的 history 个数,包含当前页面在内。举个例子,对于新开一个 tab 加载的页面当前属性返回值 1。
语法
length = history.length;
例子
js
var result = window.history.length; // 返回当前 session 中的 history 个数
规范
Specification |
---|
HTML Standard # dom-history-length-dev |
浏览器兼容性
BCD tables only load in the browser
参考
- The
History
interface it belongs to.