Interface Navigation
activation: NavigationActivation | null;
canGoBack: boolean;
canGoForward: boolean;
currentEntry: NavigationHistoryEntry | null;
oncurrententrychange:
| ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any)
| null;
onnavigate: ((this: Navigation, ev: NavigateEvent) => any) | null;
onnavigateerror: ((this: Navigation, ev: ErrorEvent) => any) | null;
onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null;
transition: NavigationTransition | null;
addEventListener<K extends keyof NavigationEventMap>(
type: K,
listener: (this: Navigation, ev: NavigationEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
back(options?: NavigationOptions): NavigationResult;
dispatchEvent(event: Event): boolean;
entries(): NavigationHistoryEntry[];
forward(options?: NavigationOptions): NavigationResult;
navigate(
url: string | URL,
options?: NavigationNavigateOptions,
): NavigationResult;
reload(options?: NavigationReloadOptions): NavigationResult;
removeEventListener<K extends keyof NavigationEventMap>(
type: K,
listener: (this: Navigation, ev: NavigationEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
traverseTo(key: string, options?: NavigationOptions): NavigationResult;
updateCurrentEntry(options: NavigationUpdateCurrentEntryOptions): void;
}
Hierarchy
- EventTarget
- Navigation
Properties
Readonlyactivation
The activation read-only property of the Navigation interface returns a NavigationActivation object containing information about the most recent cross-document navigation, which "activated" this Document. The property will stay constant during same-document navigations.
ReadonlycanGoBack
The canGoBack read-only property of the Navigation interface returns true if it is possible to navigate backwards in the navigation history (i.e., the currentEntry is not the first one in the history entry list), and false if it is not.
ReadonlycanGoForward
The canGoForward read-only property of the Navigation interface returns true if it is possible to navigate forwards in the navigation history (i.e., the currentEntry is not the last one in the history entry list), and false if it is not.
ReadonlycurrentEntry
The currentEntry read-only property of the Navigation interface returns a NavigationHistoryEntry object representing the location the user is currently navigated to right now.
oncurrententrychange
onnavigate
onnavigateerror
onnavigatesuccess
Readonlytransition
The transition read-only property of the Navigation interface returns a NavigationTransition object representing the status of an in-progress navigation, which can be used to track it.
Methods
addEventListener
-
addEventListener<K extends keyof NavigationEventMap>(
type: K,
listener: (this: Navigation, ev: NavigationEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Type Parameters
- K extends keyof NavigationEventMap
Parameters
- type: K
- listener: (this: Navigation, ev: NavigationEventMap[K]) => any
Optionaloptions: boolean | AddEventListenerOptions
Returns void
-
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | AddEventListenerOptions
Returns void
back
-
The
back()method of the Navigation interface navigates backwards by one entry in the navigation history.Parameters
Optionaloptions: NavigationOptions
Returns NavigationResult
dispatchEvent
-
The
dispatchEvent()method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().Parameters
- event: Event
Returns boolean
entries
-
The
entries()method of the Navigation interface returns an array of NavigationHistoryEntry objects representing all existing history entries.Returns NavigationHistoryEntry[]
forward
-
The
forward()method of the Navigation interface navigates forwards by one entry in the navigation history.Parameters
Optionaloptions: NavigationOptions
Returns NavigationResult
navigate
-
The
navigate()method of the Navigation interface navigates to a specific URL, updating any provided state in the history entries list.Parameters
- url: string | URL
Optionaloptions: NavigationNavigateOptions
Returns NavigationResult
reload
-
The
reload()method of the Navigation interface reloads the current URL, updating any provided state in the history entries list.Parameters
Optionaloptions: NavigationReloadOptions
Returns NavigationResult
removeEventListener
-
removeEventListener<K extends keyof NavigationEventMap>(
type: K,
listener: (this: Navigation, ev: NavigationEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.Type Parameters
- K extends keyof NavigationEventMap
Parameters
- type: K
- listener: (this: Navigation, ev: NavigationEventMap[K]) => any
Optionaloptions: boolean | EventListenerOptions
Returns void
-
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | EventListenerOptions
Returns void
traverseTo
-
The
traverseTo()method of the Navigation interface navigates to the NavigationHistoryEntry identified by the given key.Parameters
- key: string
Optionaloptions: NavigationOptions
Returns NavigationResult
updateCurrentEntry
-
The
updateCurrentEntry()method of the Navigation interface updates the state of the currentEntry; used in cases where the state change will be independent of a navigation or reload.Parameters
- options: NavigationUpdateCurrentEntryOptions
Returns void
The
Navigationinterface of the Navigation API allows control over all navigation actions for the current window in one central place, including initiating navigations programmatically, examining navigation history entries, and managing navigations as they happen.MDN Reference