Navigator.serviceWorker
read-only property returns the
ServiceWorkerContainer
对象为
associated document
, which provides access to registration, removal, upgrade, and communication with the
ServiceWorker
.
The feature may not be available in private mode.
const workerContainerInstance = navigator.serviceWorker;
This code checks if the browser supports service workers.
if ('serviceWorker' in navigator) {
// Supported!
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
服务工作者
The definition of 'navigator.serviceWorker' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
serviceWorker
|
Chrome 40 |
Edge
17
|
Firefox
44
|
IE No | Opera 27 | Safari 11.1 | WebView Android 40 | Chrome Android 40 | Firefox Android 44 | Opera Android 27 | Safari iOS 11.3 | Samsung Internet Android 4.0 |
完整支持
不支持
见实现注意事项。
用户必须明确启用此特征。
Navigator
activeVRDisplays
appCodeName
appName
appVersion
battery
buildID
clipboard
connection
cookieEnabled
credentials
deviceMemory
doNotTrack
geolocation
keyboard
语言
languages
locks
maxTouchPoints
mediaDevices
mediaSession
onLine
oscpu
permissions
platform
product
productSub
serviceWorker
userAgent
vendor
vendorSub
webdriver
xr
缓存
CacheStorage
Client
Clients
ExtendableEvent
FetchEvent
InstallEvent
Navigator.serviceWorker
NotificationEvent
PeriodicSyncEvent
PeriodicSyncManager
PeriodicSyncRegistration
ServiceWorker
ServiceWorkerContainer
ServiceWorkerGlobalScope
ServiceWorkerRegistration
SyncEvent
SyncManager
SyncRegistration
WindowClient