Service Workers API
The updatefound event of the
ServiceWorkerRegistration interface is fired any time the ServiceWorkerRegistration.installing property acquires a new service worker.
Syntax
Use the event name in EventTarget/addEventListener:
addEventListener("updatefound", (event) => { })
Alternatively, assign to the event handler property of the interface:
onupdatefound = (event) => { }
Event type
A generic Event.
Examples
const registration = await navigator.serviceWorker.getRegistration();
if (registration) {
registration.addEventListener("updatefound", () => {
console.log("Service Worker update found!");
});
}
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
