URL: 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.

We’d love to hear your thoughts on the next set of proposals for the JavaScript language. You can find a description of the proposals here.
Please take two minutes to fill out our short survey.

Hinweis: Diese Funktion ist in Web Workers verfügbar.

Die protocol-Eigenschaft des URL-Interfaces ist ein String, der das Protokoll oder Schema der URL enthält, einschließlich des abschließenden ":".

Diese Eigenschaft kann festgelegt werden, um das Protokoll der URL zu ändern. Ein ":" wird an den angegebenen String angehängt, falls nicht vorhanden. Das angegebene Schema muss mit dem Rest der URL kompatibel sein, um als gültig zu gelten.

Wert

Ein String.

Beispiele

js
const url = new URL(
  "https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol",
);
console.log(url.protocol); // Logs "https:"

Spezifikationen

Specification
URL
# dom-url-protocol

Browser-Kompatibilität

Siehe auch

  • Das URL-Interface, zu dem es gehört.