NavigationDestination: thuộc tính url
Baseline
2026
Newly available
Since January 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Thuộc tính chỉ đọc url của giao diện NavigationDestination trả về URL đang được điều hướng đến.
Giá trị
Một chuỗi.
Ví dụ
>Xử lý điều hướng bằng intercept()
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);
},
});
}
});
Thông số kỹ thuật
| Specification |
|---|
| HTML> # the-navigationdestination-interface:dom-navigationdestination-url-2> |