Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Use self.origin
instead.
The Document.origin
read-only property returns the document's origin. In most cases, this property is equivalent to document.defaultView.location.origin
.
Syntax
var origin = document.origin;
Examples
var origin = document.origin; // On this page, returns:'https://developer.mozilla.org' var origin = document.origin; // On "about:blank", returns:'null' var origin = document.origin; // On "data:text/html,<b>foo</b>", returns:'null'
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 No support 41 — 71 | Edge No support 12 — 79 | Firefox No support No | IE Full support Yes | Opera No support 28 — 58 | Safari Full support Yes | WebView Android No support 41 — 71 | Chrome Android No support 41 — 71 | Firefox Android No support No | Opera Android No support 28 — 50 | Safari iOS Full support Yes | Samsung Internet Android No support 4.0 — 10.0 |
Legend
- Full support
- Full support
- No support
- No support
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
See also
- The
URLUtils.origin
property.