Table of Contents

Class NavigateEvent

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Experimental
The NavigateEvent interface of the {{domxref("Navigation API", "Navigation API", "", "nocode")}} is the event object for the Navigationnavigate event, which fires when any type of navigation is initiated (this includes usage of {{domxref("History API", "History API", "", "nocode")}} features like Go(long)). NavigateEvent provides access to information about that navigation, and allows developers to intercept and control the navigation handling.
[Value("NavigateEvent")]
public class NavigateEvent : Event
Inheritance
NavigateEvent
Inherited Members

Remarks

Constructors

NavigateEvent()

public NavigateEvent()

NavigateEvent(string, NavigateEventInit)

NOTE
Experimental
The NavigateEvent() constructor creates a new NavigateEvent object instance.
public NavigateEvent(string type, NavigateEventInit eventInitDict)

Parameters

type string
eventInitDict NavigateEventInit

Remarks

Properties

CanIntercept

NOTE
Experimental
The canIntercept read-only property of the
NavigateEvent interface returns true if the navigation can be intercepted and have its URL rewritten, or false otherwise
[Value("canIntercept")]
public bool CanIntercept { get; }

Property Value

bool

A boolean value—true if the navigation can be intercepted, false if not.

Remarks

There are several rules around when a navigation can be intercepted. For example:

See the spec for more explanation on when a Document can have its URL rewritten, including a table of examples.

-Modern client-side routing: the Navigation API
-Navigation API explainer

See also on MDN

Destination

NOTE
Experimental
The destination read-only property of the
NavigateEvent interface returns a NavigationDestination object representing the destination being navigated to.
[Value("destination")]
public NavigationDestination Destination { get; }

Property Value

NavigationDestination

A NavigationDestination object.

Remarks

DownloadRequest

NOTE
Experimental
The downloadRequest read-only property of the
NavigateEvent interface returns the filename of the file requested for download, in the case of a download navigation (e.g., an {{htmlelement("a")}} or {{htmlelement("area")}} element with a download attribute), or null otherwise.
[Value("downloadRequest")]
public string? DownloadRequest { get; }

Property Value

string

A string containing the filename of the file requested for download, or null.

Remarks

FormData

NOTE
Experimental
The formData read-only property of the
NavigateEvent interface returns the FormData object representing the submitted data in the case of a POST form submission, or null otherwise.
[Value("formData")]
public FormData? FormData { get; }

Property Value

FormData

A FormData object, or null.

Remarks

HasUAVisualTransition

NOTE
Experimental
The hasUAVisualTransition read-only property of the NavigateEvent interface returns true if the user agent performed a visual transition for this navigation before dispatching this event, or false otherwise.
[Value("hasUAVisualTransition")]
public bool HasUAVisualTransition { get; }

Property Value

bool

A boolean value.

Remarks

User agents may provide a built-in visual transition when executing site navigations. If the site author also adds a visual transition, user agent and author transitions may conflict and confuse a visitor. The property lets you detect whether a UA transition was provided so that you can skip author transitions for a better user experience.

-Modern client-side routing: the Navigation API
-Navigation API explainer
-Same-document view transitions for single-page applications

See also on MDN

HashChange

NOTE
Experimental
The hashChange read-only property of the
NavigateEvent interface returns true if the navigation is a fragment navigation (i.e., to a fragment identifier in the same document), or false otherwise.
[Value("hashChange")]
public bool HashChange { get; }

Property Value

bool

A boolean value—true if the navigation is a fragment navigation, false if not.

Remarks

Info

NOTE
Experimental
The info read-only property of the
NavigateEvent interface returns the info data value passed by the initiating navigation operation (e.g., Back(NavigationOptions), or Navigate(string, NavigationNavigateOptions)), or undefined if no info data was passed.
[Value("info")]
public dynamic Info { get; }

Property Value

dynamic

The info value passed by the initiating navigation operation, or undefined if none was passed.

Remarks

NavigationType

NOTE
Experimental
The navigationType read-only property of the
NavigateEvent interface returns the type of the navigation — push, reload, replace, or traverse.
[Value("navigationType")]
public NavigationType NavigationType { get; }

Property Value

NavigationType

An enumerated value representing the type of navigation.The possible values are:

Remarks

Signal

NOTE
Experimental
The signal read-only property of the
NavigateEvent interface returns an AbortSignal, which will become aborted if the navigation is cancelled (e.g., by the user pressing the browser's "Stop" button, or another navigation starting and thus cancelling the ongoing one).
[Value("signal")]
public AbortSignal Signal { get; }

Property Value

AbortSignal

An AbortSignal object.

Remarks

UserInitiated

NOTE
Experimental
The userInitiated read-only property of the
NavigateEvent interface returns true if the navigation was initiated by the user (e.g., by clicking a link, submitting a form, or pressing the browser's "Back"/"Forward" buttons), or false otherwise.
[Value("userInitiated")]
public bool UserInitiated { get; }

Property Value

bool

A boolean value—true if the navigation is user-initiated, false if not.

Remarks

Methods

Intercept(NavigationInterceptOptions)

NOTE
Experimental
The intercept() method of the
NavigateEvent interface intercepts this navigation, turning it into a same-document navigation to the Url URL.
[Value("intercept")]
public GlobalObject.Undefined Intercept(NavigationInterceptOptions options = null)

Parameters

options NavigationInterceptOptions

Returns

GlobalObject.Undefined

None (undefined).

Remarks

Scroll()

NOTE
Experimental
The scroll() method of the
NavigateEvent interface can be called to manually trigger the browser-driven scrolling behavior that occurs in response to the navigation, if you want it to happen before the navigation handling has completed.
[Value("scroll")]
public GlobalObject.Undefined Scroll()

Returns

GlobalObject.Undefined

None (undefined).

Remarks