aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/url/username/index.html
blob: d57967fc8478f888d1ebc1469ee3fb5d8d3a381e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: URL.username
slug: Web/API/URL/username
tags:
  - API
  - Property
  - Reference
  - URL
  - username
translation_of: Web/API/URL/username
---
<div>{{ApiRef("URL API")}}</div>

<p> {{domxref("URL")}}接口的username属性是{{domxref("USVString")}} ,其中包含域名前指定的<strong><code>username</code></strong> 。</p>

<p>{{AvailableInWorkers}}</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox"><em>string</em> = <em>object</em>.username;
<em>object</em>.username = <em>string</em>;
</pre>

<h3 id="值"></h3>

<p>一个 {{domxref("USVString")}}.</p>

<h2 id="例子">例子</h2>

<pre class="brush: js">var url = new URL("https://anonymous:flabada@developer.mozilla.org/en-US/docs/Web/API/URL/username");
var user = url.username; // 返回:“anonymous”
</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">说明</th>
  </tr>
  <tr>
   <td>{{SpecName('URL', '#dom-url-username', 'username')}}</td>
   <td>{{Spec2('URL')}}</td>
   <td>初步定义</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("api.URL.username")}}</p>

<h2 id="参考">参考</h2>

<ul>
 <li>所属的 {{domxref("URL")}}接口。</li>
</ul>