Class NavigateEvent
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
NOTE
ExperimentalNavigateEvent 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
-Modern client-side routing: the Navigation API
-Navigation API explainer
-Navigation API live demo (view demo source)
Constructors
NavigateEvent()
public NavigateEvent()
NavigateEvent(string, NavigateEventInit)
public NavigateEvent(string type, NavigateEventInit eventInitDict)
Parameters
typestringeventInitDictNavigateEventInit
Remarks
Properties
CanIntercept
NOTE
ExperimentalcanIntercept read-only property of theNavigateEvent 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—
trueif the navigation can be intercepted,falseif 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
Destination
NOTE
Experimentaldestination read-only property of theNavigateEvent 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
ExperimentaldownloadRequest read-only property of theNavigateEvent 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
ExperimentalformData read-only property of theNavigateEvent 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
Remarks
HasUAVisualTransition
NOTE
ExperimentalhasUAVisualTransition 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
HashChange
NOTE
ExperimentalhashChange read-only property of theNavigateEvent 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—
trueif the navigation is a fragment navigation,falseif not.
Remarks
Info
NOTE
Experimentalinfo read-only property of theNavigateEvent 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
infovalue passed by the initiating navigation operation, orundefinedif none was passed.
Remarks
-Modern client-side routing: the Navigation API
-Navigation API explainer
-Methods that allow info to be passed — Back(NavigationOptions), Forward(NavigationOptions), Navigate(string, NavigationNavigateOptions), Reload(NavigationReloadOptions), and TraverseTo(string, NavigationOptions)
NavigationType
NOTE
ExperimentalnavigationType read-only property of theNavigateEvent 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
Experimentalsignal read-only property of theNavigateEvent 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
ExperimentaluserInitiated read-only property of theNavigateEvent 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—
trueif the navigation is user-initiated,falseif not.
Remarks
NOTE
The table found at Appendix: types of navigations shows which navigation types are user-initiated.
-Modern client-side routing: the Navigation API
-Navigation API explainer
Methods
Intercept(NavigationInterceptOptions)
NOTE
Experimentalintercept() method of theNavigateEvent 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
optionsNavigationInterceptOptions
Returns
- GlobalObject.Undefined
None (
undefined).
Remarks
Scroll()
NOTE
Experimentalscroll() method of theNavigateEvent 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).