Firefox Tomorrow

web api event

WorkerGlobalScope: offline event

View on MDN ↗

Available in workers

The offline event of the WorkerGlobalScope fires when the device loses connection to the internet.

Syntax

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

addEventListener("offline", (event) => { })

onoffline = (event) => { }

Event type

A generic Event.

Example

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

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

The same snippet, but using addEventListener():

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

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also

The WorkerGlobalScope interface it belongs to.