这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

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.
实时标准 初始定义。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: