Javascript DOM onoffline Event

Introduction

Execute a JavaScript when the browser starts to work offline:

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() {//from   ww  w .ja  v  a2 s .c  o m
  document.getElementById("demo").innerHTML = "Your browser is working online.";
}

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

</body>
</html>

The onoffline event occurs when the browser starts to work offline.

The onoffline event is the opposite of the ononline event.

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



PreviousNext

Related