Back to Content

NavigateEvent: sourceElement property

files/en-us/web/api/navigateevent/sourceelement/index.md

latest1.2 KB
Original Source

{{APIRef("Navigation API")}}

The sourceElement read-only property of the {{domxref("NavigateEvent")}} interface returns an {{domxref("Element")}} object representing the initiating element, in cases where the navigation was initiated by an element.

The initiating element can be:

Value

An {{domxref("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

{{Specifications}}

Browser compatibility

{{Compat}}

See also