Class NavigationHistoryEntry
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
NOTE
ExperimentalNavigationHistoryEntry 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)
Constructors
NavigationHistoryEntry()
public NavigationHistoryEntry()
Properties
Id
NOTE
Experimentalid 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
idof 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
Index
NOTE
Experimentalindex 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
indexof the entry in the history entries list, or-1if this item does not appear in the list.
Remarks
Key
NOTE
Experimentalkey 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
keyof 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
Ondispose
[Value("ondispose")]
public EventHandlerNonNull Ondispose { get; set; }
Property Value
SameDocument
NOTE
ExperimentalsameDocument 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
Experimentalurl 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
ExperimentalgetState() 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.