--- title: URL slug: Web/API/URL tags: - API - Experimental - NeedsTranslation - TopicStub - URL API translation_of: Web/API/URL ---
URL
介面提供了建立 URL
物件的靜態方法。
使用尚未實作此物件的瀏覽器時,可以改用 {{domxref("Window.URL")}} 屬性來呼叫(基於 Webkit 或 Blink 引擎的瀏覽器可使用 Window.webkitURL
)。
{{AvailableInWorkers}}
':'
.':'
, and the port of the URL.'/'
followed by the path of the URL.'?'
followed by the parameters of the URL.'#'
followed by the fragment identifier of the URL.URL
object composed from the given parameters.The URL
interface implements methods defined in {{domxref("URLUtils")}}.
blob:
as its scheme, followed by an opaque string uniquely identifying the object in the browser.Specification | Status | Comment |
---|---|---|
{{SpecName('File API', '#creating-revoking', 'URL')}} | {{Spec2('File API')}} | Added the static methods URL.createObjectURL() and URL.revokeObjectURL () . |
{{SpecName('URL', '#api', 'Node')}} | {{Spec2('URL')}} | Initial definition (implements URLUtils ). |
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 8.0[2] 32 |
{{CompatUnknown}} | {{CompatGeckoDesktop("2.0")}}[1][3] {{CompatGeckoDesktop("19.0")}} |
10.0 | 15.0[2] 19 |
6.0[2] 7.0 |
username , password , and origin |
32 | {{CompatUnknown}} | {{CompatGeckoDesktop("26.0")}} | {{CompatUnknown}} | 19 | {{CompatVersionUnknown}} |
searchParams |
{{CompatChrome(49)}} | {{CompatUnknown}} | {{CompatGeckoDesktop("29.0")}} | {{CompatUnknown}} | 36 | {{CompatNo}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 4[2] 4.4 |
8.0[2] 32 |
{{CompatGeckoMobile("14.0")}}[1][3] {{CompatGeckoMobile("19.0")}} |
{{CompatVersionUnknown}} | 15.0[2] | 6.0[2] |
username , password , and origin |
4.4 | 32 | {{CompatGeckoDesktop("26.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
searchParams |
{{CompatNo}} | {{CompatChrome(49)}} | {{CompatGeckoMobile("29.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] From Gecko 2 (Firefox 4) to Gecko 18 included, Gecko supported this interface with the non-standard nsIDOMMozURLProperty
internal type. As the only to access such an object was through {{domxref("window.URL")}}, in practice, this didn't make any difference.
[2] This feature is implemented under the non-standard name webkitURL
.
[3] For Firefox, to use from chrome code, JSM and Bootstrap scope, you have to import it like this:
Cu.importGlobalProperties(['URL']);
URL
is available in Worker scopes.