Navigation

The Navigation interface 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

Properties

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

The currentEntry read-only property of the Navigation interface returns a NavigationHistoryEntry object representing the location the user is currently navigated to right now.

Link copied to clipboard

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.

Functions

Link copied to clipboard
fun back(options: NavigationOptions = definedExternally): NavigationResult

The back() method of the Navigation interface navigates backwards by one entry in the navigation history.

Link copied to clipboard
open fun dispatchEvent(event: Event): Boolean
Link copied to clipboard

The entries() method of the Navigation interface returns an array of NavigationHistoryEntry objects representing all existing history entries.

Link copied to clipboard
fun forward(options: NavigationOptions = definedExternally): NavigationResult

The forward() method of the Navigation interface navigates forwards by one entry in the navigation history.

Link copied to clipboard
fun navigate(url: String, options: NavigationNavigateOptions = definedExternally): NavigationResult

The navigate() method of the Navigation interface navigates to a specific URL, updating any provided state in the history entries list.

fun navigate(url: URL, options: NavigationNavigateOptions = definedExternally): NavigationResult
Link copied to clipboard
fun reload(options: NavigationReloadOptions = definedExternally): NavigationResult

The reload() method of the Navigation interface reloads the current URL, updating any provided state in the history entries list.

Link copied to clipboard
fun traverseTo(key: String, options: NavigationOptions = definedExternally): NavigationResult

The traverseTo() method of the Navigation interface navigates to the NavigationHistoryEntry identified by the given key.

Link copied to clipboard

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.

Link copied to clipboard