HTMLAnchorElement.protocol

The HTMLAnchorElement.protocol property is a USVString representing the protocol scheme of the URL, including the final ':'.

Syntax

// Getter
string = anchor.protocol;
// Setter
anchor.protocol = string;

Examples

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

Specifications

Specification
HTML Living Standard
The definition of 'HTMLHyperlinkElementUtils.protocol' in that specification.

Browser compatibility

BCD tables only load in the browser

See also