Call a function when the browser starts to work offline:
<body onoffline="myFunction()">
Try it Yourself »
More examples below.
The onoffline
event occurs when the browser starts to work offline.
The onoffline
event is the opposite of the ononline
event.
You can also use the navigator.onLine property to find out if the browser offline.
In JavaScript, using the addEventListener() method:
object.addEventListener("offline",
myScript);
Try it Yourself »
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
HTML tags: | <body> |
DOM Version: | Level 3 Events |
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 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!