The NavigationDestination interface of the Navigation API represents the destination being navigated to in the current navigation.
It is accessed via the NavigateEvent.destination property.
Instance properties
id Read only Experimental
-
Returns the id value of the destination NavigationHistoryEntry if the NavigateEvent.navigationType is traverse, or null otherwise.
index Read only Experimental
-
Returns the index value of the destination NavigationHistoryEntry if the NavigateEvent.navigationType is traverse, or -1 otherwise.
key Read only Experimental
-
Returns the key value of the destination NavigationHistoryEntry if the NavigateEvent.navigationType is traverse, or null otherwise.
sameDocument Read only Experimental
-
Returns true if the navigation is to the same document as the current Document value, or false otherwise.
url Read only Experimental
-
Returns the URL being navigated to.
Instance methods
getState() Experimental
-
Returns a clone of the available state associated with the destination NavigationHistoryEntry, or navigation operation (e.g. navigate()) as appropriate.
Examples
navigation.addEventListener("navigate", (event) => {
if (shouldNotIntercept(event)) {
return;
}
const url = new URL(event.destination.url);
if (url.pathname.startsWith("/articles/")) {
event.intercept({
async handler() {
renderArticlePagePlaceholder();
const articleContent = await getArticleContent(url.pathname);
renderArticlePage(articleContent);
},
});
}
});
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
NavigationDestination |
102 |
102 |
No |
No |
88 |
No |
102 |
102 |
No |
70 |
No |
19.0 |
getState |
102 |
102 |
No |
No |
88 |
No |
102 |
102 |
No |
70 |
No |
19.0 |
id |
102 |
102 |
No |
No |
88 |
No |
102 |
102 |
No |
70 |
No |
19.0 |
index |
102 |
102 |
No |
No |
88 |
No |
102 |
102 |
No |
70 |
No |
19.0 |
key |
102 |
102 |
No |
No |
88 |
No |
102 |
102 |
No |
70 |
No |
19.0 |
sameDocument |
102 |
102 |
No |
No |
88 |
No |
102 |
102 |
No |
70 |
No |
19.0 |
url |
102 |
102 |
No |
No |
88 |
No |
102 |
102 |
No |
70 |
No |
19.0 |
See also