HTMLAnchorElement: origin property

The origin read-only property of the HTMLAnchorElement interface returns a string containing the Unicode serialization of the origin of the <a> element's href.

The exact structure varies depending on the type of URL:

For all other cases, the string "null" is returned.

See URL.origin for more information.

Value

A string.

Examples

js
// An <a id="myAnchor" href="https://developer.mozilla.org/en-US/HTMLAnchorElement"> element is in the document
const anchor = document.getElementById("myAnchor");
anchor.origin; // returns 'https://developer.mozilla.org'

Specifications

See also