files/en-us/web/api/navigation/updatecurrententry/index.md
{{APIRef("Navigation API")}}
The updateCurrentEntry() method of the {{domxref("Navigation")}} interface updates the state of the {{domxref("Navigation.currentEntry","currentEntry")}}; used in cases where the state change will be independent of a navigation or reload.
updateCurrentEntry(options)
options
state
state must be structured-cloneable.None (undefined).
DataCloneError {{domxref("DOMException")}}
state parameter had values included in it that are not structured-cloneable.InvalidStateError {{domxref("DOMException")}}
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 {{htmlelement("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 } });
});
{{Specifications}}
{{Compat}}