Location: protocol-Eigenschaft

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.

Die protocol-Eigenschaft des Location-Interfaces ist ein String, der das Protokoll oder Schema der URL des Standorts enthält, einschließlich des abschließenden ":". Wenn der Port der Standardport für das Protokoll ist (80 für ws: und http:, 443 für wss: und https: sowie 21 für ftp:), enthält diese Eigenschaft einen leeren String, "".

Diese Eigenschaft kann gesetzt werden, um das Protokoll der URL zu ändern. Ein ":" wird an den bereitgestellten String angehängt, falls es nicht angegeben wurde. Das bereitgestellte Schema muss mit dem Rest der URL kompatibel sein, um als gültig angesehen zu werden.

Sehen Sie sich URL.protocol für weitere Informationen an.

Wert

Ein String.

Beispiele

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:'

Spezifikationen

Specification
HTML
# dom-location-protocol-dev

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
protocol

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
User must explicitly enable this feature.