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
Browser compatibility
| Desktop | Mobile |
---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Android webview | Chrome for Android | Firefox for Android | Opera for Android | Safari on iOS | Samsung Internet |
---|
offline event | Chrome
Full support
Yes | Edge
Full support
12 | Firefox
Full support
Yes | IE
Full support
Yes | Opera
Full support
Yes | Safari
Full support
Yes | WebView Android
Full support
Yes | Chrome Android
Full support
Yes | Firefox Android
Full support
Yes | Opera Android
Full support
Yes | Safari iOS
Full support
Yes | Samsung Internet Android
Full support
Yes |
---|
Legend
-
Full support
- Full support
See also