Javascript DOM onoffline Event via HTML Tag onoffline attribute

Introduction

Open the File menu and click on "Work Offline" to toggle between working online and offline.

The ononline and onoffline events are supported in Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body ononline="onFunction()" onoffline="offFunction()">
<p id="demo"></p>
<script>
function onFunction() {// w w  w  .  j a  va2  s  .com
  document.getElementById("demo").innerHTML = "Your browser is working online.";
}

function offFunction() {
  document.getElementById("demo").innerHTML = "Your browser is working offline.";
}
</script>

</body>
</html>
Bubbles: No
Cancelable: No
Event type: Event
Supported HTML tags: <body>



PreviousNext

Related