The offline event of the Window interface is fired when the browser has lost access to the network and the value of Navigator.onLine switches to false.

Bubbles No
Cancelable No
Interface Event
Event handler property onoffline

Examples

// addEventListener version
window.addEventListener('offline', (event) => {
    console.log("The network connection has been lost.");
});

// onoffline version
window.onoffline = (event) => {
  console.log("The network connection has been lost.");
};

Specifications

Specification Status
HTML Living Standard
The definition of 'offline event' in that specification.
Living Standard

Browser compatibility

No compatibility data found. Please contribute data for "api.Window.offline_event" (depth: 1) to the MDN compatibility data repository.

See also

Document Tags and Contributors

Last updated by: chrisdavidmills,