WorkerGlobalScope: origin property
Note: This feature is only available in Web Workers.
The origin
read-only property of the WorkerGlobalScope
interface returns the origin of the global scope, serialized as a string.
Value
A string.
Examples
Executed from inside worker scope, the following snippet will log the worker's global scope's origin to the console each time it receives a message.
js
self.onmessage = () => {
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
Specification |
---|
HTML # dom-origin-dev |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
origin |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
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.
See also
Window.origin
- origin glossary term