URL
Experimental: 這是一個實驗中的功能
此功能在某些瀏覽器尚在開發中,請參考兼容表格以得到不同瀏覽器用的前輟。
URL
介面提供了建立 URL
物件的靜態方法。
使用尚未實作此物件的瀏覽器時,可以改用 Window.URL
(en-US) 屬性來呼叫(基於 Webkit 或 Blink 引擎的瀏覽器可使用 Window.webkitURL
)。
備註: 此功能可在 Web Worker 中使用
屬性
URL.href
(en-US)-
Is a
DOMString
containing the whole URL. URL.protocol
(en-US)-
Is a
DOMString
containing the protocol scheme of the URL, including the final':'
. URL.host
(en-US)-
Is a
DOMString
containing the host, that is the hostname, a':'
, and the port of the URL. URL.hostname
(en-US)-
Is a
DOMString
containing the domain of the URL. URL.port
(en-US)-
Is a
DOMString
containing the port number of the URL. URL.pathname
(en-US)-
Is a
DOMString
containing an initial'/'
followed by the path of the URL. URL.search
(en-US)-
Is a
DOMString
containing a'?'
followed by the parameters of the URL. URL.hash
(en-US)-
Is a
DOMString
containing a'#'
followed by the fragment identifier of the URL. URL.username
(en-US)-
Is a
DOMString
containing the username specified before the domain name. URL.password
(en-US)-
Is a
DOMString
containing the password specified before the domain name. URL.origin
(en-US) Read only-
Returns a
DOMString
containing the origin of the URL, that is its scheme, its domain and its port. URL.searchParams
(en-US)-
Returns a
URLSearchParams
(en-US) object allowing to access the GET query arguments contained in the URL.
建構式
URL()
(en-US)-
Creates and return a
URL
object composed from the given parameters.
方法
The URL
interface implements methods defined in URLUtils
.
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.
靜態方法
URL.createObjectURL()
-
Returns a
DOMString
containing a unique blob URL, that is a URL withblob:
as its scheme, followed by an opaque string uniquely identifying the object in the browser. URL.revokeObjectURL()
(en-US)-
Revokes an object URL previously created using
URL.createObjectURL()
.
規範
Specification |
---|
URL Standard # api |
瀏覽器相容性
BCD tables only load in the browser
參見
- Property allowing to get such an object:
Window.URL
(en-US). - Components.utils.importGlobalProperties