aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/api/url/index.html
blob: 6f1bb536860dd39453bfbbbadfa4353bd9dc6087 (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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
---
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>The <strong><code>URL</code></strong><strong> </strong>interface represent an object providing static methods used for creating object URLs.</p>

<p>When using a user agent where no constructor has been implemented yet, it is possible to access such an object using the {{domxref("Window.URL")}} properties (prefixed with Webkit-based browser as <code>Window.webkitURL</code>).</p>

<h2 id="Properties">Properties</h2>

<p><em>Implements properties defined in {{domxref("URLUtils")}}.</em></p>

<dl>
 <dt>{{domxref("URLUtils.href")}}</dt>
 <dd>Is a {{domxref("DOMString")}} containing the whole URL.</dd>
 <dt>{{domxref("URLUtils.protocol")}}</dt>
 <dd>Is a {{domxref("DOMString")}} containing the protocol scheme of the URL, including the final <code>':'</code>.</dd>
 <dt>{{domxref("URLUtils.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("URLUtils.hostname")}}</dt>
 <dd>Is a {{domxref("DOMString")}} containing the domain of the URL.</dd>
 <dt>{{domxref("URLUtils.port")}}</dt>
 <dd>Is a {{domxref("DOMString")}} containing the port number of the URL.</dd>
 <dt>{{domxref("URLUtils.pathname")}}</dt>
 <dd>Is a {{domxref("DOMString")}} containing an initial <code>'/'</code> followed by the path of the URL.</dd>
 <dt>{{domxref("URLUtils.search")}}</dt>
 <dd>Is a {{domxref("DOMString")}} containing a <code>'?'</code> followed by the parameters of the URL.</dd>
 <dt>{{domxref("URLUtils.hash")}}</dt>
 <dd>Is a {{domxref("DOMString")}} containing a <code>'#'</code> followed by the fragment identifier of the URL.</dd>
 <dt>{{domxref("URLUtils.username")}}</dt>
 <dd>Is a {{domxref("DOMString")}} containing the username specified before the domain name.</dd>
 <dt>{{domxref("URLUtils.password")}}</dt>
 <dd>Is a {{domxref("DOMString")}} containing the password specified before the domain name.</dd>
 <dt>{{domxref("URLUtils.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("URLUtils.searchParams")}}</dt>
 <dd>Returns a {{domxref("URLSearchParams")}} object allowing to access the GET query arguments contained in the URL.</dd>
</dl>

<h2 id="Constructor">Constructor</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="Methods">Methods</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="Static_methods">Static methods</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="Specifications">Specifications</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="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>8.0 as <code>webkitURL</code><br>
    35</td>
   <td>{{CompatGeckoDesktop("2.0")}} (non-standard name) [1]<br>
    {{CompatGeckoDesktop("19.0")}}</td>
   <td>10.0</td>
   <td>15.0 as <code>webkitURL<br>
    {{CompatVersionUnknown}}</code></td>
   <td>6.0 as <code>webkitURL</code><br>
    7.0</td>
  </tr>
  <tr>
   <td><code>URLUtils</code> properties</td>
   <td>32</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>19</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>username</code>, <code>password</code>, and <code>origin</code></td>
   <td>32</td>
   <td>{{CompatGeckoDesktop("26.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>19</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>protocol, host, hostname, port, href</code>, <code>pathname</code>, <code>search</code>, <code>hash</code></td>
   <td>32</td>
   <td>{{CompatGeckoDesktop("22.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>19</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>searchParams</code></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoDesktop("29.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>19</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}as <code>webkitURL</code></td>
   <td>{{CompatGeckoMobile("14.0")}}(non-standard name) [1]<br>
    {{CompatGeckoMobile("19.0")}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>15.0 as <code>webkitURL</code></td>
   <td>
    <p>6.0 as <code>webkitURL</code></p>

    <p> </p>
   </td>
  </tr>
  <tr>
   <td><code>URLUtils </code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>username</code>, <code>password</code>, <code>href</code>, and <code>origin</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("26.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] From Gecko 2 (Firefox 4) to Gecko 18 included, Gecko supported this interface with the non-standard <code>nsIDOMMozURLProperty</code> internal type. As the only to access such an object was through {{domxref("window.URL")}}, in practice, this didn't make any difference.</p>

<h2 id="Chrome_Code_-_Scope_Availability">Chrome Code - Scope Availability</h2>

<p>To use from chrome code, JSM and Bootstrap scope, you have to import it like this:</p>

<pre class="brush: js">Cu.importGlobalProperties(['URL']);
</pre>

<p><code>URL</code> is available in Worker scopes.</p>

<h2 id="See_also">See also</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>