名称 只读特性在 SharedWorkerGlobalScope interface returns the name that the SharedWorker was (optionally) given when it was created. This is the name that the SharedWorker() constructor can pass to get a reference to the SharedWorkerGlobalScope .

句法

var nameObj = self.name;
					

A DOMString .

范例

If a shared worker is created using a constructor with a 名称 选项:

var myWorker = new SharedWorker("worker.js", { name : "mySharedWorker" });
					

the SharedWorkerGlobalScope will now have a name of "mySharedWorker", returnable by running

self.name
					

from inside the shared worker.

规范

规范 状态 注释
HTML 实时标准
The definition of 'name' in that specification.
实时标准

浏览器兼容性

The compatibility table in 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
名称 Chrome Yes Edge ≤79 Firefox 55 IE No Opera 10.6 Safari No WebView Android Yes Chrome Android 40 Firefox Android 55 Opera Android Yes Safari iOS No Samsung Internet Android 4.0

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改: