The controllerchange
event of the ServiceWorkerContainer
interface fires when the document's associated ServiceWorkerRegistration
acquires a new active
worker.
The controllerchange
event of the ServiceWorkerContainer
interface fires when the document's associated ServiceWorkerRegistration
acquires a new active
worker.
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("controllerchange", (event) => {}); oncontrollerchange = (event) => {};
A generic Event
.
js
navigator.serviceWorker.addEventListener("controllerchange", () => { console.log("The controller of current browsing context has changed."); });
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
controllerchange_event |
40 | 17 | 44 | No | 27 | 11.1 | 40 | 40 | 44 | 27 | 11.3 | 4.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controllerchange_event