--- 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> <p>{{AvailableInWorkers}}</p> <h2 id="Свойства">Свойства</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="Конструктор">Конструктор</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>Добавлены статические методы <code>URL.createObjectURL()</code>, <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> <p>{{Compat("api.URL")}}</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 notranslate">Cu.importGlobalProperties(['URL']); </pre> <p><code>URL</code> is available in Worker scopes.</p> <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>