onoffline event
Definition and usage
The onoffline event occurs when the browser starts to work offline.
Tip:onoffline event with ononline-händelse Conversely.
Tip:You can also use navigator.onLine property to determine whether the browser is in online or offline mode.
Example
Execute JavaScript when the browser starts to work offline:
<body onoffline="myFunction()">
Syntax
In HTML:
<element onoffline="myScript">
In JavaScript:
object.onoffline = function(){myScript};
In JavaScript, use the addEventListener() method:
object.addEventListener("offline", myScript);
Note:Internet Explorer 8 or earlier versions do not support addEventListener() method.
Technical details
Bubbling: | Ej stödd |
---|---|
Cancellable: | Ej stödd |
Event type: | Event |
Supported HTML tags: | <body> |
DOM version: | Level 3 Events |
Webbläsarstöd
Talen i tabellen anger den första webbläsareversion som fullständigt stöder denna händelse.
Händelser | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
onoffline | Ej stödd. | Föråldrad från IE11 8.0 |
3.0 | Ej stödd | Ej stödd |