Table of Contents

Class Navigation

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Experimental
The Navigation interface of the {{domxref("Navigation API", "Navigation API", "", "nocode")}} 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.
[Value("Navigation")]
public class Navigation : EventTarget
Inheritance
Navigation
Inherited Members

Remarks

It is accessed via the Navigation property.

The Navigation API only exposes history entries created in the current browsing context that have the same origin as the current page (e.g., not navigations inside embedded iframes, or cross-origin navigations), providing an accurate list of all previous history entries just for your app. This makes traversing the history a much less fragile proposition than with the older {{domxref("History API", "History API", "", "nocode")}}.

-Modern client-side routing: the Navigation API
-Navigation API explainer
-Navigation API live demo (view demo source)

See also on MDN

Constructors

Navigation()

public Navigation()

Properties

Activation

NOTE
Experimental
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.
[Value("activation")]
public NavigationActivation? Activation { get; }

Property Value

NavigationActivation

A NavigationActivation object, or null if current document is the initial about:blank document.

Remarks

CanGoBack

NOTE
Experimental
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.
[Value("canGoBack")]
public bool CanGoBack { get; }

Property Value

bool

A boolean value: true if it is possible to navigate backwards in the navigation history, false otherwise.

Remarks

CanGoForward

NOTE
Experimental
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.
[Value("canGoForward")]
public bool CanGoForward { get; }

Property Value

bool

A boolean value: true if it is possible to navigate forwards in the navigation history, false otherwise.

Remarks

CurrentEntry

NOTE
Experimental
The currentEntry read-only property of the
Navigation interface returns a NavigationHistoryEntry object representing the location the user is currently navigated to right now.
[Value("currentEntry")]
public NavigationHistoryEntry? CurrentEntry { get; }

Property Value

NavigationHistoryEntry

A NavigationHistoryEntry object.

Remarks

Oncurrententrychange

[Value("oncurrententrychange")]
public EventHandlerNonNull Oncurrententrychange { get; set; }

Property Value

EventHandlerNonNull

Onnavigate

[Value("onnavigate")]
public EventHandlerNonNull Onnavigate { get; set; }

Property Value

EventHandlerNonNull

Onnavigateerror

[Value("onnavigateerror")]
public EventHandlerNonNull Onnavigateerror { get; set; }

Property Value

EventHandlerNonNull

Onnavigatesuccess

[Value("onnavigatesuccess")]
public EventHandlerNonNull Onnavigatesuccess { get; set; }

Property Value

EventHandlerNonNull

Transition

NOTE
Experimental
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.
[Value("transition")]
public NavigationTransition? Transition { get; }

Property Value

NavigationTransition

A NavigationTransition object, or null if no navigation is currently in progress.

Remarks

Methods

Back(NavigationOptions)

NOTE
Experimental
The back() method of the
Navigation interface navigates backwards by one entry in the navigation history.
[Value("back")]
public NavigationResult Back(NavigationOptions options = null)

Parameters

options NavigationOptions

Returns

NavigationResult

An object with the following properties:Either one of these promises rejects if the navigation has failed for some reason.

Remarks

Entries()

NOTE
Experimental
The entries() method of the
Navigation interface returns an array of NavigationHistoryEntry objects representing all existing history entries.
[Value("entries")]
public List<NavigationHistoryEntry> Entries()

Returns

List<NavigationHistoryEntry>

An array of NavigationHistoryEntry objects.

Remarks

Forward(NavigationOptions)

NOTE
Experimental
The forward() method of the
Navigation interface navigates forwards by one entry in the navigation history.
[Value("forward")]
public NavigationResult Forward(NavigationOptions options = null)

Parameters

options NavigationOptions

Returns

NavigationResult

An object with the following properties:Either one of these promises rejects if the navigation has failed for some reason.

Remarks

Navigate(string, NavigationNavigateOptions)

NOTE
Experimental
The navigate() method of the
Navigation interface navigates to a specific URL, updating any provided state in the history entries list.
[Value("navigate")]
public NavigationResult Navigate(string url, NavigationNavigateOptions options = null)

Parameters

url string
options NavigationNavigateOptions

Returns

NavigationResult

An object with the following properties:Either one of these promises rejects if the navigation has failed for some reason.

Remarks

Reload(NavigationReloadOptions)

NOTE
Experimental
The reload() method of the
Navigation interface reloads the current URL, updating any provided state in the history entries list.
[Value("reload")]
public NavigationResult Reload(NavigationReloadOptions options = null)

Parameters

options NavigationReloadOptions

Returns

NavigationResult

An object with the following properties:Either one of these promises rejects if the navigation has failed for some reason.

Remarks

TraverseTo(string, NavigationOptions)

NOTE
Experimental
The traverseTo() method of the Navigation interface navigates to the NavigationHistoryEntry identified by the given Key.
[Value("traverseTo")]
public NavigationResult TraverseTo(string key, NavigationOptions options = null)

Parameters

key string
options NavigationOptions

Returns

NavigationResult

An object with the following properties:Either one of these promises rejects if the navigation has failed for some reason.

Remarks

UpdateCurrentEntry(NavigationUpdateCurrentEntryOptions)

NOTE
Experimental
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.
[Value("updateCurrentEntry")]
public GlobalObject.Undefined UpdateCurrentEntry(NavigationUpdateCurrentEntryOptions options)

Parameters

options NavigationUpdateCurrentEntryOptions

Returns

GlobalObject.Undefined

None (undefined).

Remarks