WorkerGlobalScope: online event

The online event of the WorkerGlobalScope fires when the device reconnects to the internet.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener("online", (event) => {});

ononline = (event) => {};

Event type

A generic Event.

Example

The following code snippet shows an onoffline handler set inside a worker:

self.ononline = () => {
  console.log("Your worker is now online");
};

The same snippet, but using addEventListener():

self.addEventListener("online", () => {
  console.log("Your worker is now online");
});

Specifications

Specification
HTML Standard
# handler-workerglobalscope-ononline

Browser compatibility

BCD tables only load in the browser

See also

The WorkerGlobalScope interface it belongs to.