这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
origin
只读特性在
WindowOrWorkerGlobalScope
interface returns the origin of the global scope, serialized as a string.
var myOrigin = self.origin; // or just origin
A
USVString
.
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"
.
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'WindowOrWorkerGlobalScope.origin' in that specification. |
实时标准 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
origin
|
Chrome 59 | Edge ≤79 | Firefox 54 | IE No | Opera No | Safari No | WebView Android 59 | Chrome Android 59 | Firefox Android 54 | Opera Android No | Safari iOS No | Samsung Internet Android 7.0 |
完整支持
不支持