web api instance method
NavigationDestination: getState() method
The getState() method of the
NavigationDestination interface returns a clone of the developer-supplied state associated with the destination NavigationHistoryEntry, or navigation operation (e.g., navigate()) as appropriate.
Syntax
getState()
Parameters
None.
Return value
A value representing the state. This can be any type.
If no state is defined, it returns undefined.
Exceptions
None.
Examples
navigation.addEventListener("navigate", (event) => {
console.log(event.destination.getState());
});
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
- Modern client-side routing: the Navigation API
- Navigation API explainer
- Methods that allow state to be updated —
navigate(),reload(), andupdateCurrentEntry()