HTMLHyperlinkElementUtils

这是 实验性技术
检查 浏览器兼容性表格 在生产中使用这之前。

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.

特性

注意: 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 包含 URL 的协议方案,包括最终的 ':' .
HTMLHyperlinkElementUtils.host
This is a USVString 包含主机,即 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 ':' ,和 port of the URL.
HTMLHyperlinkElementUtils.hostname
This is a USVString 包含 URL 的域。
HTMLHyperlinkElementUtils.port
This is a USVString 包含 URL 的端口号。
HTMLHyperlinkElementUtils.pathname
This is a USVString 包含初始 '/' followed by the path of the URL.
HTMLHyperlinkElementUtils.search
This is a USVString 包含 '?' followed by the parameters of the URL.
HTMLHyperlinkElementUtils.hash
This is a USVString 包含 '#' 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 只读
This returns a USVString containing the origin of the URL (that is its scheme, its domain and its port).

方法

注意: 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.

规范

规范 状态 Comment
HTML Living Standard
The definition of 'HTMLHyperlinkElementUtils' in that specification.
实时标准 初始定义

浏览器兼容性

更新 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 Yes
Yes
Starting in Chrome 52, the members of this interface were moved to URL
Edge 12 Firefox 22
22
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.
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 5 Opera Yes
Yes
Starting in Opera 39, the members of this interface were moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, the members of this interface were moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, the members of this interface were moved to URL
Firefox Android 22
22
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.
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 Yes
Yes
Starting in Opera 39, the members of this interface were moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, the members of this interface were moved to URL
hash Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 12 Firefox 22
22
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 5 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 22
22
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
host Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 12 Firefox 22
22
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 5
5
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 22
22
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
hostname Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 12 Firefox 22
22
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 5 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 22
22
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
href Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 12 Firefox 22
22
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 5 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 22
22
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
origin Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 17 Firefox 26
26
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.
Before Firefox 49, results for URL using the blob scheme incorrectly returned null .
IE No Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 26
26
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.
Before Firefox 49, results for URL using the blob scheme incorrectly returned null .
Opera Android Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
password Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 79 Firefox 26
26
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 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 26
26
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
pathname Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 12 Firefox 22
22
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.
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 5 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 22
22
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.
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
port Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 12 Firefox 22
22
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 5 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 22
22
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
protocol Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 12 Firefox 22
22
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 5 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 22
22
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
search Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 12 Firefox 22
22
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.
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 5 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 22
22
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.
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL
toString Chrome 52 Edge ≤18 Firefox 22
22
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 Opera Yes Safari Yes WebView Android 52 Chrome Android 52 Firefox Android 22
22
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 Yes Safari iOS Yes Samsung Internet Android 6.0
username Chrome Yes
Yes
Starting in Chrome 52, this property was moved to URL
Edge 79 Firefox 26
26
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 Opera Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari Yes WebView Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Chrome Android Yes
Yes
Starting in Chrome 52, this property was moved to URL
Firefox Android 26
26
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 Yes
Yes
Starting in Opera 39, this property was moved to URL
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting in Samsung Internet 6.0, this property was moved to URL

图例

完整支持
完整支持
不支持
不支持
见实现注意事项。

另请参阅