URL

Это экспериментальная технология
Так как спецификация этой технологии ещё не стабилизировалась, смотрите таблицу совместимости по поводу использования в различных браузерах. Также заметьте, что синтаксис и поведение экспериментальной технологии может измениться в будущих версиях браузеров, вслед за изменениями спецификации.

The URL interface represent an object providing static methods used for creating object URLs.

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

Примечание: Эта возможность доступна в Web Workers.

Свойства

Implements properties defined in URLUtils.

URLUtils.href
Is a DOMString containing the whole URL.
URLUtils.protocol
Is a DOMString containing the protocol scheme of the URL, including the final ':'.
URLUtils.host
Is a DOMString containing the host, that is the hostname, a ':', and the port of the URL.
URLUtils.hostname
Is a DOMString containing the domain of the URL.
URLUtils.port
Is a DOMString containing the port number of the URL.
URLUtils.pathname
Is a DOMString containing an initial '/' followed by the path of the URL.
URLUtils.search
Is a DOMString containing a '?' followed by the parameters of the URL.
URLUtils.hash
Is a DOMString containing a '#' followed by the fragment identifier of the URL.
URLUtils.username
Is a DOMString containing the username specified before the domain name.
URLUtils.password
Is a DOMString containing the password specified before the domain name.
URLUtils.origin Только для чтения
Returns a DOMString containing the origin of the URL, that is its scheme, its domain and its port.
URLUtils.searchParams
Returns a URLSearchParams object allowing to access the GET query arguments contained in the URL.

Конструктор

URL()
Creates and return a URL object composed from the given parameters.

Методы

The URL interface implements methods defined in URLUtils.

URLUtils.toString()
Returns a DOMString containing the whole URL. It is a synonym for URLUtils.href, though it can't be used to modify the value.

Статические методы

URL.createObjectURL()
Returns a DOMString containing a unique blob URL, that is a URL with blob: as its scheme, followed by an opaque string uniquely identifying the object in the browser.
URL.revokeObjectURL()
Revokes an object URL previously created using URL.createObjectURL().

Спецификации

Specification Status Comment
File API
Определение 'URL' в этой спецификации.
Рабочий черновик Добавлены статические методы URL.createObjectURL(), URL.revokeObjectURL().
URL
Определение 'Node' в этой спецификации.
Живой стандарт Initial definition (implements URLUtils).

Поддержка браузерами

BCD tables only load in the browser

Chrome Code - Scope Availability

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

Cu.importGlobalProperties(['URL']);

URL is available in Worker scopes.

См. также