Web/API/HTMLHyperlinkElementUtils

From Get docs

This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.


The HTMLHyperlinkElementUtils mixin defines utility methods and properties to work with HTMLAnchorElement and HTMLAreaElement. These utilities allow to deal with common features like URLs.

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

Properties

Note: This interface doesn't inherit any property.


HTMLHyperlinkElementUtils.href
This a stringifier property that returns a USVString containing the whole URL, and allows the href to be updated.
HTMLHyperlinkElementUtils.protocol
This is a USVString containing the protocol scheme of the URL, including the final ':'.
HTMLHyperlinkElementUtils.host
This is a USVString 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.
HTMLHyperlinkElementUtils.hostname
This is a USVString containing the domain of the URL.
HTMLHyperlinkElementUtils.port
This is a USVString containing the port number of the URL.
HTMLHyperlinkElementUtils.pathname
Is a USVString containing an initial '/' followed by the path of the URL, not including the query string or fragment.
HTMLHyperlinkElementUtils.search
This is a USVString containing a '?' followed by the parameters of the URL.
HTMLHyperlinkElementUtils.hash
This is a USVString containing a '#' followed by the fragment identifier of the URL.
HTMLHyperlinkElementUtils.username
This is a USVString containing the username specified before the domain name.
HTMLHyperlinkElementUtils.password
This is a USVString containing the password specified before the domain name.
HTMLHyperlinkElementUtils.origin Read only
This returns a USVString containing the origin of the URL (that is its scheme, its domain and its port).

Methods

Note: This interface doesn't inherit any method.


HTMLHyperlinkElementUtils.toString()
This returns a USVString containing the whole URL. It is a synonym for HTMLHyperlinkElementUtils.href, though it can't be used to modify the value.

Specifications

Specification Status Comment
HTML Living StandardThe definition of 'HTMLHyperlinkElementUtils' in that specification. Living Standard Initial definition

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
HTMLHyperlinkElementUtils

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, the members of this interface were moved to URL

Edge

Full support 12

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' This mixin was called URLUtils before Firefox 45, and was also implemented to other by other interfaces, like Location. From Firefox 45, the other interfaces implement their own version of the properties and methods they need. Notes' Firefox was a bug whereby single contained in URLs are escaped when accessed via URL APIs (bug 1386683). This has been as of Firefox 57.

IE

Full support 5

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, the members of this interface were moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, the members of this interface were moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, the members of this interface were moved to URL

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' This mixin was called URLUtils before Firefox 45, and was also implemented to other by other interfaces, like Location. From Firefox 45, the other interfaces implement their own version of the properties and methods they need. Notes' Firefox was a bug whereby single contained in URLs are escaped when accessed via URL APIs (bug 1386683). This has been as of Firefox 57.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, the members of this interface were moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, the members of this interface were moved to URL

hash

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 12

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Also, from Firefox 29 to Firefox 40, the returned value was incorrectly percent-decoded.

IE

Full support 5

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Also, from Firefox 29 to Firefox 40, the returned value was incorrectly percent-decoded.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

host

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 12

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

IE Full support 5

Notes'

Full support 5

Notes'

Notes' In Internet Explorer 9, the host of an <a> always include the port (e.g. developer.mozilla.org:443), even if there is no explicit port in the href attribute value.

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

hostname

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 12

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

IE

Full support 5

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

href

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 12

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

IE

Full support 5

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

origin

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 17

Firefox Full support 26

Notes'

Full support 26

Notes'

Notes' From Firefox 26 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Notes' Before Firefox 49, results for URL using the blob scheme incorrectly returned null.

IE

No support No

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 26

Notes'

Full support 26

Notes'

Notes' From Firefox 26 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Notes' Before Firefox 49, results for URL using the blob scheme incorrectly returned null.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

password

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 79

Firefox Full support 26

Notes'

Full support 26

Notes'

Notes' From Firefox 26 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

IE

No support No

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 26

Notes'

Full support 26

Notes'

Notes' From Firefox 26 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

pathname

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 12

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Notes'' Before Firefox 53, the pathname and search HTMLHyperlinkElementUtils properties returned the wrong parts of the URL. For example, for a URL of http://z.com/x?a=true&b=false, pathname would return '/x?a=true&b=false' and search would return , rather than '/x' and '?a=true&b=false' respectively. This has now been fixed.

IE

Full support 5

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Notes'' Before Firefox 53, the pathname and search HTMLHyperlinkElementUtils properties returned the wrong parts of the URL. For example, for a URL of http://z.com/x?a=true&b=false, pathname would return '/x?a=true&b=false' and search would return , rather than '/x' and '?a=true&b=false' respectively. This has now been fixed.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

port

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 12

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

IE

Full support 5

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

protocol

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 12

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

IE

Full support 5

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

search

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 12

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Notes'' Before Firefox 53, the pathname and search HTMLHyperlinkElementUtils properties returned the wrong parts of the URL. For example, for a URL of http://z.com/x?a=true&b=false, pathname would return '/x?a=true&b=false' and search would return , rather than '/x' and '?a=true&b=false' respectively. This has now been fixed.

IE

Full support 5

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface. Notes'' Before Firefox 53, the pathname and search HTMLHyperlinkElementUtils properties returned the wrong parts of the URL. For example, for a URL of http://z.com/x?a=true&b=false, pathname would return '/x?a=true&b=false' and search would return , rather than '/x' and '?a=true&b=false' respectively. This has now been fixed.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

toString Chrome

Full support 52

Edge

Full support ≤18

Firefox Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

IE

No support No

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support 52

Chrome Android

Full support 52

Firefox Android Full support 22

Notes'

Full support 22

Notes'

Notes' From Firefox 22 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support 6.0

username

Chrome Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Edge

Full support 79

Firefox Full support 26

Notes'

Full support 26

Notes'

Notes' From Firefox 26 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

IE

No support No

Opera Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari

Full support Yes

WebView Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Chrome Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Chrome 52, this property was moved to URL

Firefox Android Full support 26

Notes'

Full support 26

Notes'

Notes' From Firefox 26 to Firefox 44, this property was on the URLUtils mixin. It has been moved either on the HTMLHyperlinkElementUtils mixin, or directly on the interface.

Opera Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Opera 39, this property was moved to URL

Safari iOS

Full support Yes

Samsung Internet Android Full support Yes

Notes'

Full support Yes

Notes'

Notes' Starting in Samsung Internet 6.0, this property was moved to URL

Legend

Full support  
Full support
No support  
No support
See implementation notes.'
See implementation notes.


See also