--- title: URL.密码 slug: Web/API/URL/password translation_of: Web/API/URL/password original_slug: Web/API/URL/密码 ---
{{ApiRef("URL API")}}

 {{domxref("URL")}}接口的password属性为{{domxref("USVString")}},其中包含在域名之前指定的密码。

如果在未设置username属性的情况下进行调用,默认失败。

{{AvailableInWorkers}}

语法

string = object.password;
object.password = string;

A {{domxref("USVString")}}.

Examples

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")}}

参见