demo · v135
Which element navigated me?
Chrome 135 adds sourceElement to NavigateEvent so the navigation.addEventListener("navigate", …) handler knows whether the navigation came from a specific <a>, <form>, or programmatic call. Click each trigger below and see what the handler reports.
the code
navigation.addEventListener("navigate", (e) => {
console.log({
url: e.destination.url,
sourceElement: e.sourceElement?.tagName,
sourceElementId: e.sourceElement?.id,
userInitiated: e.userInitiated,
});
});
see also
- NavigateEvent.sourceElement — feature index
- ChromeStatus entry