Table of Contents

Class NavigationHistoryEntry

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Experimental
The NavigationHistoryEntry interface of the {{domxref("Navigation API", "Navigation API", "", "nocode")}} represents a single navigation history entry.
[Value("NavigationHistoryEntry")]
public class NavigationHistoryEntry : EventTarget
Inheritance
NavigationHistoryEntry
Inherited Members

Remarks

These objects are commonly accessed via the CurrentEntry property and Entries() method.

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

NavigationHistoryEntry()

public NavigationHistoryEntry()

Properties

Id

NOTE
Experimental
The id read-only property of the NavigationHistoryEntry interface returns the id of the history entry, or an empty string if current document is not fully active. This is a unique, UA-generated value that always represents a specific history entry, useful to correlate it with an external resource such as a storage cache.
[Value("id")]
public string Id { get; }

Property Value

string

A string representing the id of the NavigationHistoryEntry.

Remarks

This differs from the Key of a history entry. The key is a unique, UA-generated value that represents the history entry's slot in the entries list rather than the entry itself. It is used to navigate that particular slot via TraverseTo(string, NavigationOptions). The key will be reused by other entries that replace the entry in the list (that is, if the NavigationType is replace).

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

See also on MDN

Index

NOTE
Experimental
The index read-only property of the NavigationHistoryEntry interface returns the index of the history entry in the history entries list (that is, the list returned by Entries()), or -1 if the entry does not appear in the list or if current document is not fully active.
[Value("index")]
public long Index { get; }

Property Value

long

A number representing the index of the entry in the history entries list, or -1 if this item does not appear in the list.

Remarks

Key

NOTE
Experimental
The key read-only property of the NavigationHistoryEntry interface returns the key of the history entry, or an empty string if current document is not fully active. This is a unique, UA-generated value that represents the history entry's slot in the entries list. It is used to navigate that particular slot via TraverseTo(string, NavigationOptions). The key will be reused by other entries that replace the entry in the list (that is, if the NavigationType is replace).
[Value("key")]
public string Key { get; }

Property Value

string

A string representing the key of the NavigationHistoryEntry.

Remarks

This differs from the Id of a history entry. The id is a unique, UA-generated value that always represents a specific history entry rather than its slot in the entries list. This is useful to correlate it with an external resource such as a storage cache.

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

See also on MDN

Ondispose

[Value("ondispose")]
public EventHandlerNonNull Ondispose { get; set; }

Property Value

EventHandlerNonNull

SameDocument

NOTE
Experimental
The sameDocument read-only property of the NavigationHistoryEntry interface returns true if this history entry is for the same document as the current Document value and current document is fully active, or false otherwise.
[Value("sameDocument")]
public bool SameDocument { get; }

Property Value

bool

A boolean.

Remarks

Url

NOTE
Experimental
The url read-only property of the NavigationHistoryEntry interface returns the absolute URL of this history entry. If the entry corresponds to a different Document than the current one (like sameDocument property is false), and that Document was fetched with a Referrer-Policy header set to no-referrer or origin, the property returns null. If current document is not fully active, it returns an empty string.
[Value("url")]
public string? Url { get; }

Property Value

string

A string representing the URL or null.

Remarks

Methods

GetState()

NOTE
Experimental
The getState() method of the NavigationHistoryEntry interface returns a clone of the developer-supplied state associated with this history entry.
[Value("getState")]
public dynamic GetState()

Returns

dynamic

A value representing the state. This can be any structured-cloneable data type.If no state is defined or if current document is not fully active, it returns undefined.

Remarks