dom / latest / origin.html /

origin

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The global origin read-only property returns the origin of the global scope, serialized as a string.

Value

Examples

Executed from inside a worker script, the following snippet will log the worker's global scope's origin to the console each time it receives a message

onmessage = function() {
  console.log(self.origin);
};

If the origin is not a scheme/host/port tuple (say you are trying to run it locally, i.e. via file:// URL), origin will return the string "null".

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
origin
59
18
54
No
46
11
59
59
54
43
11
7.0
worker_support
59
18
54
No
46
11
59
59
54
43
11
7.0

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/origin