This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The Document.origin
read-only property returns the document's origin. In most cases, this property is equivalent to document.defaultView.location.origin
.
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'
Specification | Status | Comment |
---|---|---|
DOM The definition of 'Document.origin' in that specification. | Living Standard | Initial definition. |
HTML Living Standard The definition of 'origin for various objects (including Document objects)' in that specification. | Living Standard | Initial definition. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 41 | ? | No | Yes | Yes | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | 41 | ? | No | Yes | ? | ? |
URLUtils.origin
property.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/document/origin