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
httporhttpsURLs, the scheme followed by'://', followed by the domain, followed by':', followed by the port (the default port,80and443respectively, if explicitely 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"will be returned as"https://mozilla.org".
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 |
|---|---|---|
| URL The 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.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
origin | Chrome Full support 32 | Edge Full support 12 | Firefox
Full support
26
| 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
| 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
URLinterface
