NavigationHistoryEntry:id 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

NavigationHistoryEntry 接口的 id 只读属性返回历史条目的 id,如果当前文档未完全激活,则返回空字符串。这是一个唯一的 UA 生成值,始终代表特定历史条目,可用于将其与外部资源(如存储缓存)关联。

这与历史条目的 key 不同。key 是一个唯一的 UA 生成值,代表历史条目在条目列表中的位置,而不是条目本身。它用于通过 Navigation.traverseTo() 导航该特定位置。key 将被替换列表中条目的其他条目重用(即,如果 NavigateEvent.navigationTypereplace)。

表示 NavigationHistoryEntryid 的字符串。

示例

js
const current = navigation.currentEntry;
console.log(current.id);

规范

Specification
HTML
# dom-navigationhistoryentry-id-dev

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
id
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.

参见