Client

Client interface represents an executable context such as a Worker ,或 SharedWorker . Window clients are represented by the more-specific WindowClient . You can get Client / WindowClient objects from methods such as Clients.matchAll() and Clients.get() .

方法

Client.postMessage()
Sends a message to the client.

特性

Client.id 只读
The universally unique identifier of the client as a string.
Client.type 只读
The client's type as a string. It can be " window" , " worker" , or " sharedworker" .
Client.url 只读
The URL of the client as a string.

规范

规范 状态 Comment
服务工作者
The definition of 'Client' in that specification.
工作草案 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Client
Chrome 40 Edge 17 Firefox 44
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
IE No Opera 27 Safari No WebView Android 40 Chrome Android 40 Firefox Android 44 Opera Android 27 Safari iOS No Samsung Internet Android 4.0
frameType
Chrome 43 Edge 17 Firefox 44
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
IE No Opera 30 Safari No WebView Android 43 Chrome Android 43 Firefox Android 44 Opera Android 30 Safari iOS No Samsung Internet Android 4.0
id
Chrome 40 Edge ≤79 Firefox 44
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
IE No Opera 27 Safari No WebView Android 40 Chrome Android 40 Firefox Android 44 Opera Android 27 Safari iOS No Samsung Internet Android 4.0
postMessage
Chrome 45 Edge ≤79 Firefox 44
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
IE No Opera 32 Safari No WebView Android 45 Chrome Android 45 Firefox Android 44 Opera Android 32 Safari iOS No Samsung Internet Android 5.0
type
Chrome 60 Edge ≤79 Firefox 54 IE No Opera 47 Safari No WebView Android 60 Chrome Android 60 Firefox Android 54 Opera Android 44 Safari iOS No Samsung Internet Android 8.0
url
Chrome 40 Edge ≤79 Firefox 44
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
IE No Opera 27 Safari No WebView Android 40 Chrome Android 40 Firefox Android 44 Opera Android 27 Safari iOS No Samsung Internet Android 4.0

图例

完整支持
完整支持
不支持
不支持
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
见实现注意事项。

另请参阅