Location: protocol property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The protocol
property of the Location
interface is a string representing the protocol scheme of the URL,
including the final ':'
.
Value
A string.
Examples
js
// Let's an <a id="myAnchor" href="https://developer.mozilla.org/en-US/Location.protocol"> element be in the document
const anchor = document.getElementById("myAnchor");
const result = anchor.protocol; // Returns:'https:'
Specifications
Specification |
---|
HTML Standard # dom-location-protocol-dev |
Browser compatibility
BCD tables only load in the browser