NavigationCurrentEntryChangeEvent
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.
TheNavigationCurrentEntryChangeEvent interface of theNavigation API is the event object for thecurrententrychange event, which fires when theNavigation.currentEntry has changed.
This event will fire for same-document navigations (e.g.,back() ortraverseTo()), replacements (i.e., anavigate() call withhistory set toreplace), or other calls that change the entry's state (e.g.,updateCurrentEntry(), or theHistory API'sHistory.replaceState()).
This event fires after the navigation is committed, meaning that the visible URL has changed and theNavigationHistoryEntry update has occurred. It is useful for migrating from usage of older API features like thehashchange orpopstate events.
In this article
Constructor
NavigationCurrentEntryChangeEvent()ExperimentalCreates a new
NavigationCurrentEntryChangeEventobject instance.
Instance properties
Inherits properties from its parent,Event.
fromRead onlyExperimentalReturns the
NavigationHistoryEntrythat was navigated from.navigationTypeRead onlyExperimentalReturns the type of the navigation that resulted in the change.
Examples
Navigation data reporting:
navigation.addEventListener("currententrychange", () => { const data = navigation.currentEntry.getState(); submitAnalyticsData(data.analytics);});Setting up a per-entry event:
navigation.addEventListener("currententrychange", () => { navigation.currentEntry.addEventListener("dispose", genericDisposeHandler);});Specifications
| Specification |
|---|
| HTML> # the-navigationcurrententrychangeevent-interface> |