MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

这篇翻译不完整。请帮忙从英语翻译这篇文章

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

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 只读
Returns a DOMString containing the origin of the URL, that is its scheme, its domain and its port.
URLUtils.searchParams
Returns a URLSearchParams 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
URLUtils
Living Standard Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 未实现 [1] 22 (22) [1] 未实现 [1] 未实现 [1] 未实现 [1]
searchParams ? 29 (29) 未实现 ? ?
username and password ? 26 (26) 未实现 ? ?
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 未实现 [1] 未实现 [1] 22.0 (22) [1] 未实现 [1] 未实现 [1] 未实现 [1]
searchParams ? ? 未实现 未实现 ? ?
username and password ? ? 26.0 (26) 未实现 ? ?
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




 
 

文档标签和贡献者

 此页面的贡献者: teoli
 最后编辑者: teoli,