Web/API/URL/origin

From Get docs
< Web/API‎ | URL


The origin read-only property of the URL interface returns a USVString containing the Unicode serialization of the origin of the represented URL. The exact structure varies depending on the type of URL:

  • For http or https URLs, the scheme followed by '://', followed by the domain, followed by ':', followed by the port (the default port, 80 and 443 respectively, if explicitly specified).
  • For file: URLs, the value is browser dependant.
  • for blob: URLs, the origin of the URL following blob: will be used, e.g "blob:https://mozilla.org%22 will be returned as "https://mozilla.org%22.

Note: This feature is available in Web Workers.

Syntax

const originString = url.origin

Value

A USVString.

Examples

const url = new URL("blob:https://mozilla.org:443/")
console.log(url.origin); // Logs 'https://mozilla.org'

Specifications

Specification Status Comment
URLThe definition of 'URL.origin' 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
origin Chrome

Full support 32

Edge

Full support 12

Firefox Full support 26


Full support 26


No support 26 — 49

Notes'

Notes' Results for URL using the blob scheme incorrectly returned null.

IE

No support No

Opera

Full support Yes

Safari

Full support 10

WebView Android

Full support ≤37

Chrome Android

Full support 32

Firefox Android Full support 26


Full support 26


No support 26 — 49

Notes'

Notes' Results for URL using the blob scheme incorrectly returned null.

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support 6.0

Legend

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


See also

  • The URL interface