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.

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'

Specifications

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.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support41 ? No Yes Yes ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes41 ? No Yes ? ?

See also

Document Tags and Contributors

Contributors to this page: mfuji09, sideshowbarker, fscholz, teoli, ziyunfei
Last updated by: mfuji09,