This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The updateCurrentEntry() method of the Navigation interface updates the state of the currentEntry; used in cases where the state change will be independent of a navigation or reload.
updateCurrentEntry(options)
optionsAn options object containing the following properties:
stateDeveloper-defined information to be stored in the associated NavigationHistoryEntry once the navigation is complete, retrievable via getState(). This can be any data type. You might, for example, wish to store a page visit count for analytics purposes, or store UI state details so the view can be shown exactly as the user last left it. Any data stored in state must be structured-cloneable.
None (undefined).
DataCloneError DOMException
Thrown if the state parameter had values included in it that are not structured-cloneable.
InvalidStateError DOMException
Thrown if the Navigation.currentEntry is null, i.e., there is no current history entry. This could occur for example if the current page is about:blank.
You could use something like the following to update the open/closed state of a <details> element so that the state can be restored when reloading the page or navigating back from somewhere else.
detailsElem.addEventListener("toggle", () => {
navigation.updateCurrentEntry({ state: { detailOpen: detailsElem.open } });
});
| Specification |
|---|
| HTML> # dom-navigation-updatecurrententry-dev> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
updateCurrentEntry |
102 | 102 | No | 88 | No | 102 | No | 70 | No | 19.0 | 102 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Navigation/updateCurrentEntry