MDN Web Docs

Syntax

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

js

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

Event type

A generic Event.

Example

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

js

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

The same snippet, but using addEventListener():

js

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

Specifications

Specification
HTML
# handler-workerglobalscope-onoffline

Browser compatibility

See also

The WorkerGlobalScope interface it belongs to.

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗