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
orhttps
URLs, the scheme followed by'://'
, followed by the domain, followed by':'
, followed by the port (the default port,80
and443
respectively, if explicitly specified). - For
file:
URLs, the value is browser dependant. - for
blob:
URLs, the origin of the URL followingblob:
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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
origin
|
Chrome
Full support 32 |
Edge
Full support 12 |
Firefox Full support 26 Full support 26 No support 26 — 49 Notes' Results for |
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' Results for |
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
URL.origin by Mozilla Contributors is licensed under CC-BY-SA 2.5.