URLUtils
Experimental
This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
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
(en-US), URL
(en-US), HTMLAnchorElement
(en-US), and HTMLAreaElement
(en-US).
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.searchParams
- Returns a
URLSearchParams
(en-US) 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 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
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | No support [1] | 22 (22) [1] | No support [1] | No support [1] | No support [1] |
searchParams | ? | 29 (29) | No support | ? | ? |
username and password |
? | 26 (26) | No support | ? | ? |
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 | No support [1] | No support [1] | 22.0 (22) [1] | No support [1] | No support [1] | No support [1] |
searchParams | ? | ? | No support | No support | ? | ? |
username and password |
? | ? | 26.0 (26) | No support | ? | ? |
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
(en-US),URLUtils
, andURLSearchParams
(en-US). - Interfaces implementing this one:
Location
(en-US),HTMLAnchorElement
(en-US),HTMLAreaElement
(en-US).