NavigateEvent: destination-Eigenschaft
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.
Die schreibgeschützte Eigenschaft destination des NavigateEvent-Interfaces gibt ein NavigationDestination-Objekt zurück, das das Ziel repräsentiert, zu dem navigiert wird.
Wert
Ein NavigationDestination-Objekt.
Beispiele
js
navigation.addEventListener("navigate", (event) => { // Exit early if this navigation shouldn't be intercepted, // e.g. if the navigation is cross-origin, or a download request if (shouldNotIntercept(event)) { return; } const url = new URL(event.destination.url); if (url.pathname.startsWith("/articles/")) { event.intercept({ async handler() { // The URL has already changed, so show a placeholder while // fetching the new content, such as a spinner or loading page renderArticlePagePlaceholder(); // Fetch the new content and display when ready const articleContent = await getArticleContent(url.pathname); renderArticlePage(articleContent); }, }); } }); Spezifikationen
| Specification |
|---|
| HTML> # dom-navigateevent-destination-dev> |
Browser-Kompatibilität
Loading…