Execute a JavaScript when the browser starts to work online:
Open the File menu and click on "Work Offline" to toggle between working online and offline.
The ononline and onoffline events are only supported in Firefox and Internet Explorer version 8 to 10.
<!DOCTYPE html> <html> <body ononline="onFunction()" onoffline="offFunction()"> <p id="demo"></p> <script> function onFunction() {//from www . jav a2 s. c om document.getElementById("demo").innerHTML = "Your browser is working online."; } function offFunction() { document.getElementById("demo").innerHTML = "Your browser is working offline."; } </script> </body> </html>
The ononline event occurs when the browser starts to work online.
The ononline event is the opposite of the onoffline event.
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <body> |
DOM Version: | Level 3 Events |