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
DOMStringcontaining the whole URL. URLUtils.protocol- Is a
DOMStringcontaining the protocol scheme of the URL, including the final':'. URLUtils.host- Is a
DOMStringcontaining 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
DOMStringcontaining the domain of the URL. URLUtils.port- Is a
DOMStringcontaining the port number of the URL. URLUtils.pathname- Is a
DOMStringcontaining an initial'/'followed by the path of the URL. URLUtils.search- Is a
DOMStringcontaining a'?'followed by the parameters of the URL. URLUtils.hash- Is a
DOMStringcontaining a'#'followed by the fragment identifier of the URL. URLUtils.username- Is a
DOMStringcontaining the username specified before the domain name. URLUtils.password- Is a
DOMStringcontaining the password specified before the domain name. URLUtils.originRead only- Returns a
DOMStringcontaining the origin of the URL, that is its scheme, its domain and its port. URLUtils.searchParams- Returns a
URLSearchParamsobject allowing to access the GET query arguments contained in the URL.
Methods
This interface doesn't inherit any method.
URLUtils.toString()- Returns a
DOMStringcontaining the whole URL. It is a synonym forURLUtils.href, though it can't be used to modify the value.
Specifications
| Specification | Status | Comment |
|---|---|---|
| URL The definition of 'URLUtils' in that specification. |
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] |
| searchParams | Not supported | 29 (29) | Not supported | ? | ? |
username and password |
? | 26 (26) | Not supported | ? | ? |
origin |
(Yes) | 26 (26) | ? | ? | ? |
origin on Windows.location |
(Yes) | 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] |
| searchParams | ? | ? | 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
- Other URL-related interfaces:
URL,URLUtils, andURLSearchParams. - Interfaces implementing this one:
Location,HTMLAnchorElement,HTMLAreaElement.