NavigationHistoryEntry:url 属性
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 接口的 url 只读属性返回此历史记录条目的绝对 URL。如果该条目对应的文档与当前文档不同(例如 sameDocument 属性为 false),并且该文档是在 Referrer-Policy 标头设置为 no-referrer 或 origin 的情况下获取的,则该属性返回 null。如果当前文档未完全激活,则返回一个空字符串。
值
表示 URL 的字符串或 null。
示例
js
const current = navigation.currentEntry;
console.log(current.url);
规范
| Specification |
|---|
| HTML> # dom-navigationhistoryentry-url-dev> |
浏览器兼容性
参见
- 现代客户端路由:导航 API
- 导航 API 说明
- Domenic Denicola 的导航 API 在线演示