Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Navigation
  4. updateCurrentEntry()

Navigation: updateCurrentEntry() method

Limited availability

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

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

TheupdateCurrentEntry() method of theNavigation interface updates thestate of thecurrentEntry; used in cases where the state change will be independent of a navigation or reload.

Syntax

js
updateCurrentEntry(options)

Parameters

options

An options object containing the following properties:

state

Developer-defined information to be stored in the associatedNavigationHistoryEntry once the navigation is complete, retrievable viagetState(). 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 instate must bestructured-cloneable.

Return value

None (undefined).

Exceptions

DataCloneErrorDOMException

Thrown if thestate parameter had values included in it that are not structured-cloneable.

InvalidStateErrorDOMException

Thrown if theNavigation.currentEntry isnull, i.e., there is no current history entry. This could occur for example if the current page isabout:blank.

Examples

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.

js
detailsElem.addEventListener("toggle", () => {  navigation.updateCurrentEntry({ state: { detailOpen: detailsElem.open } });});

Specifications

Specification
HTML
# dom-navigation-updatecurrententry-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp