URL.protocol

URL接口的 protocol 是一个包含 URL 协议的USVString值,此值包含协议后的':'.

备注: 此特性在 Web Worker 中可用

语法

string = object.protocol;
object.protocol = string;

参数

示例

js
var url = new URL(
  "https://developer.mozilla.org/zh-CN/docs/Web/API/URL/protocol",
);
var result = url.protocol; // Returns:"https:"

规范

Specification
URL Standard
# dom-url-protocol

浏览器兼容性

BCD tables only load in the browser

其他链接

  • The URL interface it belongs to.