Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The postMessage()
method of the ServiceWorker
interface sends a message to the worker. The first parameter is the data to send to the worker. The data may be any JavaScript object which can be handled by the structured clone algorithm.
The service worker can send back information to its clients by using the postMessage()
method. The message will not be sent back to this ServiceWorker
object but to the associated ServiceWorkerContainer
available via navigator.serviceWorker
.