Navigator.serviceWorker

Navigator.serviceWorker 只读属性,返回 关联文件 的 ServiceWorkerContainer 对象,它提供对ServiceWorker 的注册,删除,升级和通信的访问。。

语法

let workerContainerInstance = navigator.serviceWorker;

ServiceWorkerContainer.

规范

Specification Status Comment
Service Workers
navigator.serviceWorker
Working Draft Initial definition.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 40.0 44.0 (44.0)[1] 未实现 24 未实现
Feature Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support ? 44.0 (44.0) (Yes) 未实现 ? 未实现 ?

[1] Service workers (and Push) have been disabled in the Firefox 45 Extended Support Release (ESR.)

也可以看看