Window: offline event
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
.
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 |
---|
HTML Standard (HTML) # event-offline |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
offline_event |
Yes |
12 |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Window/offline_event