onoffline Event
Example
Call a function when the browser starts to work offline:
<body onoffline="myFunction()">
Try it Yourself »
More examples below.
Description
The onoffline
event occurs when the browser starts to work offline.
The onoffline
event is the opposite of the
ononline
event.
Note
You can also use the navigator.onLine property to find out if the browser offline.
Syntax
In JavaScript, using the addEventListener() method:
object.addEventListener("offline", myScript);
Try it Yourself »
Technical Details
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
HTML tags: | <body> |
DOM Version: | Level 3 Events |
Browser Support
onoffline
is a DOM Level 3 (2004) feature.
It is fully supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |