--- title: URL.protocol slug: Web/API/URL/protocol translation_of: Web/API/URL/protocol ---
protocol是一个包含URL协议的{{domxref("USVString")}}值,此值包含协议后的':'.{{AvailableInWorkers}}
string = object.protocol; object.protocol = string;
A {{domxref("USVString")}}.
var url = new URL('https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol');
var result = url.protocol; // Returns:"https:"
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('URL', '#dom-url-protocol', 'protocol')}} | {{Spec2('URL')}} | Initial definition. |
{{Compat("api.URL.protocol")}}