clientId
只读特性在
FetchEvent
interface returns the id of the
Client
that the current service worker is controlling.
Clients.get()
method could then be passed this ID to retrieve the associated client.
var myClientId = fetchEvent.clientId;
A
DOMString
that represents the client ID.
self.addEventListener('fetch', function(event) {
console.log(event.clientId);
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
服务工作者
The definition of 'clientId' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
clientId
|
Chrome 49 | Edge ≤79 |
Firefox
45
注意事项
|
IE 不支持 No | Opera 36 | Safari 不支持 No | WebView Android 49 | Chrome Android 49 | Firefox Android 45 | Opera Android 36 | Safari iOS 不支持 No | Samsung Internet Android 5.0 |
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
FetchEvent
缓存
CacheStorage
Client
Clients
ExtendableEvent
InstallEvent
Navigator.serviceWorker
NotificationEvent
PeriodicSyncEvent
PeriodicSyncManager
PeriodicSyncRegistration
ServiceWorker
ServiceWorkerContainer
ServiceWorkerGlobalScope
ServiceWorkerRegistration
SyncEvent
SyncManager
SyncRegistration
WindowClient