The URL.origin read-only property returns a USVString containing the Unicode serialization of the origin of the represented URL, that is:

  • for URL using the http or https, the scheme followed by '://', followed by the domain, followed by ':', followed by the port (the default port, 80 and 443 respectively, if explicitely specified);
  • for URL using file: scheme, the value is browser dependant;
  • for URL using the blob: scheme, the origin of the URL following blob:. E.g "blob:https://mozilla.org" will have "https://mozilla.org".

Note: This feature is available in Web Workers.

Syntax

string = URLObject.origin;

Examples

var result = new URL("blob:https://mozilla.org:443/").origin;
// Returns:'https://developer.mozilla.org:443'

Specifications

Specification Status Comment
URL
The definition of 'URL.origin' in that specification.
Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 52Edge Full support 12
Notes
Full support 12
Notes
Notes Defined in another interface but available to use from URL.
Firefox Full support 26
Full support 26
No support 26 — 44
Notes
Notes This property was on the URLUtils mixin. It has been moved either to the HTMLHyperlinkElementUtils mixin, or directly on the interface.
No support 26 — 49
Notes
Notes Results for URL using the blob scheme incorrectly returned null.
IE ? Opera Full support Yes
Notes
Full support Yes
Notes
Notes Defined in another interface but available to use from URL.
Safari Full support 10
Notes
Full support 10
Notes
Notes Defined in another interface but available to use from URL.
WebView Android Full support 52Chrome Android Full support 52Edge Mobile Full support 12
Notes
Full support 12
Notes
Notes Defined in another interface but available to use from URL.
Firefox Android Full support 26
Full support 26
No support 26 — 44
Notes
Notes This property was on the URLUtils mixin. It has been moved either to the HTMLHyperlinkElementUtils mixin, or directly on the interface.
No support 26 — 49
Notes
Notes Results for URL using the blob scheme incorrectly returned null.
Opera Android Full support Yes
Notes
Full support Yes
Notes
Notes Defined in another interface but available to use from URL.
Safari iOS Full support Yes
Notes
Full support Yes
Notes
Notes Defined in another interface but available to use from URL.
Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also

Document Tags and Contributors

Contributors to this page: fscholz, chrisdavidmills, erikadoyle, jpmedley, teoli
Last updated by: fscholz,