Back to Content

NavigationDestination: getState() method

files/en-us/web/api/navigationdestination/getstate/index.md

latest1.1 KB
Original Source

{{APIRef("Navigation API")}}

The getState() method of the {{domxref("NavigationDestination")}} interface returns a clone of the developer-supplied state associated with the destination {{domxref("NavigationHistoryEntry")}}, or navigation operation (e.g., {{domxref("Navigation.navigate()", "navigate()")}}) as appropriate.

Syntax

js-nolint
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

js
navigation.addEventListener("navigate", (event) => {
  console.log(event.destination.getState());
});

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also