NavigateEvent: sourceElement property
The sourceElement read-only property of the
NavigateEvent interface returns an Element object representing the initiating element, in cases where the navigation was initiated by an element.
The initiating element can be:
- An HTML
<a>element (or SVG<a>element). - An
<area>element. - A submit button (
<input type="submit">or<button type="submit">). - A submitted
<form>element.
Value
An Element object representing the element that initiated the navigation, or null if the navigation was not initiated by an element.
Examples
Getting the sourceElement for an event
js
navigation.addEventListener("navigate", (event) => {
console.log(event.sourceElement);
});
Specifications
| Specification |
|---|
| HTML # dom-navigateevent-sourceelement |
Browser compatibility
| desktop | mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
sourceElement
|
|
|
|
|
|
|
|
|
|
|
|
|
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support