--- title: Navigator.serviceWorker slug: Web/API/Navigator/serviceWorker translation_of: Web/API/Navigator/serviceWorker ---

{{APIRef("Service Workers API")}}

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

语法

let workerContainerInstance = navigator.serviceWorker;

{{domxref("ServiceWorkerContainer")}}.

规范

Specification Status Comment
{{SpecName('Service Workers', '#navigator-service-worker', 'navigator.serviceWorker')}} {{Spec2('Service Workers')}} Initial definition.

浏览器兼容性

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatChrome(40.0)}} {{ CompatGeckoDesktop("44.0") }}[1] {{CompatNo}} 24 {{CompatNo}}
Feature Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatUnknown}} {{ CompatGeckoMobile("44.0") }} {{ CompatVersionUnknown }} {{CompatNo}} {{CompatUnknown}} {{CompatNo}} {{CompatUnknown}}

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

也可以看看