NavigationHistoryEntry:index 属性
Baseline
2026
Newly available
Since January 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
NavigationHistoryEntry 接口的 index 只读属性返回历史条目在历史条目列表(即 Navigation.entries() 返回的列表)中的索引,如果条目未出现在列表中或者当前文档未处于完全活跃状态,则返回 -1。
值
表示历史条目列表中条目的 index 的数字,如果此项未出现在列表中,则为 -1。
示例
js
const current = navigation.currentEntry;
console.log(current.index);
规范
| Specification |
|---|
| HTML> # dom-navigationhistoryentry-index-dev> |
浏览器兼容性
参见
- 现代客户端路由:导航 API
- 导航 API 说明
- Domenic Denicola 的导航 API 在线演示