此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Client

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2018年4月⁩.

Client 接口表示一个可执行的上下文,如 WorkerSharedWorkerWindow 客户端由更具体的 WindowClient 表示。你可以从 Clients.matchAll()Clients.get() 等方法获取 Client/WindowClient 对象。

实例方法

Client.postMessage()

向客户端发送一条消息。

实例属性

Client.id 只读

一个字符串,表示客户端的通用唯一标识。

Client.type 只读

表示客户端类型的字符串。可能是 "window""worker""sharedworker"

Client.url 只读

表示客户端 URL 的字符串。

规范

Specification
Service Workers
# client-interface

浏览器兼容性

参见