Run ❯
zig
.
com
Result Size:
625 x 565
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>HTML DOM Events</h1> <h2>The ononline Event</h2> <p>Use the HTML DOM to assign an "ononline" and "onoffline" event to a body element.</p> <p><b>NOTE:</b> There will only be an "output" from this example when the browser shifts from offline to online.</p> <script> document.getElementsByTagName("BODY")[0].ononline = function () { onFunction() }; document.getElementsByTagName("BODY")[0].onoffline = function () { offFunction() }; function onFunction() { document.getElementById("demo").innerHTML = "Your browser is working online."; } function offFunction() { document.getElementById("demo").innerHTML = "Your browser is working offline."; } </script> </body> <!-- /jsref/tryit.asp?filename=tryjsref_ononline_dom </html>