--- title: URL.密码 slug: Web/API/URL/password translation_of: Web/API/URL/password original_slug: Web/API/URL/密码 ---
{{domxref("URL")}}接口的password
属性为{{domxref("USVString")}},其中包含在域名之前指定的密码。
如果在未设置username属性的情况下进行调用,默认失败。
{{AvailableInWorkers}}
string = object.password; object.password = string;
A {{domxref("USVString")}}.
var url = new URL('https://anonymous:flabada@developer.mozilla.org/en-US/docs/Web/API/URL/password'); var result = url.password; // Returns:"flabada"
Specification | Status | Comment |
---|---|---|
{{SpecName('URL', '#dom-url-password', 'URL.password')}} | {{Spec2('URL')}} | Initial definition. |
{{Compat("api.URL.password")}}