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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
---
title: URL
slug: Web/API/URL
tags:
- API
- Experimental
- NeedsTranslation
- TopicStub
- URL API
translation_of: Web/API/URL
---
<div>{{ApiRef("URL API")}} {{SeeCompatTable}}</div>
<p><strong><code>URL</code></strong> 介面提供了建立 <code>URL</code> 物件的靜態方法。</p>
<p>使用尚未實作此物件的瀏覽器時,可以改用 {{domxref("Window.URL")}} 屬性來呼叫(基於 Webkit 或 Blink 引擎的瀏覽器可使用 <code>Window.webkitURL</code>)。</p>
<p>{{AvailableInWorkers}}</p>
<h2 id="屬性">屬性</h2>
<dl>
<dt>{{domxref("URL.href")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing the whole URL.</dd>
<dt>{{domxref("URL.protocol")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing the protocol scheme of the URL, including the final <code>':'</code>.</dd>
<dt>{{domxref("URL.host")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing the host, that is the <em>hostname</em>, a <code>':'</code>, and the <em>port</em> of the URL.</dd>
<dt>{{domxref("URL.hostname")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing the domain of the URL.</dd>
<dt>{{domxref("URL.port")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing the port number of the URL.</dd>
<dt>{{domxref("URL.pathname")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing an initial <code>'/'</code> followed by the path of the URL.</dd>
<dt>{{domxref("URL.search")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing a <code>'?'</code> followed by the parameters of the URL.</dd>
<dt>{{domxref("URL.hash")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing a <code>'#'</code> followed by the fragment identifier of the URL.</dd>
<dt>{{domxref("URL.username")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing the username specified before the domain name.</dd>
<dt>{{domxref("URL.password")}}</dt>
<dd>Is a {{domxref("DOMString")}} containing the password specified before the domain name.</dd>
<dt>{{domxref("URL.origin")}} {{readonlyInline}}</dt>
<dd>Returns a {{domxref("DOMString")}} containing the origin of the URL, that is its scheme, its domain and its port.</dd>
</dl>
<dl>
<dt>{{domxref("URL.searchParams")}}</dt>
<dd>Returns a {{domxref("URLSearchParams")}} object allowing to access the GET query arguments contained in the URL.</dd>
</dl>
<h2 id="建構式">建構式</h2>
<dl>
<dt>{{domxref("URL.URL", "URL()")}}</dt>
<dd>Creates and return a <code>URL</code> object composed from the given parameters.</dd>
</dl>
<h2 id="方法">方法</h2>
<p><em>The <code>URL</code> interface implements methods defined in {{domxref("URLUtils")}}.</em></p>
<dl>
<dt>{{domxref("URLUtils.toString()")}}</dt>
<dd>Returns a {{domxref("DOMString")}} containing the whole URL. It is a synonym for {{domxref("URLUtils.href")}}, though it can't be used to modify the value.</dd>
</dl>
<h2 id="靜態方法">靜態方法</h2>
<dl>
<dt>{{domxref("URL.createObjectURL()")}}</dt>
<dd>Returns a {{domxref("DOMString")}} containing a unique blob URL, that is a URL with <code>blob:</code> as its scheme, followed by an opaque string uniquely identifying the object in the browser.</dd>
<dt>{{domxref("URL.revokeObjectURL()")}}</dt>
<dd>Revokes an object URL previously created using {{domxref("URL.createObjectURL()")}}.</dd>
</dl>
<h2 id="規範">規範</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('File API', '#creating-revoking', 'URL')}}</td>
<td>{{Spec2('File API')}}</td>
<td>Added the static methods <code>URL.createObjectURL()</code> and <code>URL.revokeObjectURL</code><code>()</code>.</td>
</tr>
<tr>
<td>{{SpecName('URL', '#api', 'Node')}}</td>
<td>{{Spec2('URL')}}</td>
<td>Initial definition (implements <code>URLUtils</code>).</td>
</tr>
</tbody>
</table>
<h2 id="瀏覽器相容性">瀏覽器相容性</h2>
{{Compat("api.URL")}}
<h2 id="參見">參見</h2>
<ul>
<li>Property allowing to get such an object: {{domxref("Window.URL")}}.</li>
<li><a href="/en-US/docs/Components.utils.importGlobalProperties">Components.utils.importGlobalProperties</a></li>
</ul>
|