URLUtils

« URLUtils

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

The URLUtils interface defines utility methods to work with URLs.

There are no objects of this type, but several objects implement it, such as Location, URL, HTMLAnchorElement, and HTMLAreaElement.

Properties

This interface doesn't inherit any property.

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, and then, if the port of the URL is not empty (which can happen because it was not specified or because it was specified to be the default port of the URL's scheme), 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 Read only
Returns a DOMString containing the origin of the URL, that is its scheme, its domain and its port.
URLUtils.query
Returns a URLQuery object allowing to access the GET query arguments contained in the URL.

Methods

This interface doesn't inherit any method.

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.

Specifications

Specification Status Comment
URL Living Standard Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support Not supported [1] 22 (22) [1] Not supported [1] Not supported [1] Not supported [1]
query ? Not supported Not supported ? ?
username and password ? 26 (26) Not supported ? ?
origin ? 26 (26) ? ? ?
origin on Windows.location ? 21 (21) ? ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support Not supported [1] Not supported [1] 22.0 (22) [1] Not supported [1] Not supported [1] Not supported [1]
query ? ? Not supported Not supported ? ?
username and password ? ? 26.0 (26) Not supported ? ?
origin ? ? 26.0 (26) ? ? ?
origin on Windows.location ? ? 21.0 (21) ? ? ?

[1] Though not grouped in a single abstract interface, these methods are directly available on the interfaces that implement it, if this interface is supported.

See also


Document Tags and Contributors

Contributors to this page: Bzbarsky, Annevk, teoli
Last updated by: teoli,