我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

The username property of the URL interface is a USVString containing the username specified before the domain name.

Note: This feature is available in Web Workers.

Syntax

string = object.username;
object.username = string;

Value

A USVString.

Examples

var url = new URL("https://anonymous:flabada@developer.mozilla.org/en-US/docs/Web/API/URL/username");
var user = url.username; // Returns:'anonymous'

Specifications

Specification Status Comment
URL
The definition of 'username' in that specification.
Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
usernameChrome Full support 52Edge Full support 12Firefox Full support 26IE ? Opera Full support YesSafari Full support 10WebView Android Full support 52Chrome Android Full support 52Edge Mobile Full support 12Firefox Android Full support 26Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

See also

  • The URL interface it belongs to.

文档标签和贡献者

此页面的贡献者: mdnwebdocs-bot, chrisdavidmills, teoli
最后编辑者: mdnwebdocs-bot,