Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. WorkerGlobalScope
  4. offline

WorkerGlobalScope: offline event

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Note: This feature is only available inWeb Workers.

Theoffline event of theWorkerGlobalScope fires when the device loses connection to the internet.

Syntax

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

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

Event type

A genericEvent.

Example

The following code snippet shows anonoffline handler set inside a worker:

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

The same snippet, but usingaddEventListener():

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

Specifications

Specification
HTML
# handler-workerglobalscope-onoffline

Browser compatibility

See also

TheWorkerGlobalScope interface it belongs to.

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp