Execute a JavaScript when the browser starts to work offline: - Javascript DOM Event

Javascript examples for DOM Event:onoffline

Description

Execute a JavaScript when the browser starts to work offline:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body ononline="onFunction()" onoffline="offFunction()">

<script>
function onFunction() {//from w w  w .  jav  a 2 s .c  o m
    console.log("Your browser is working online.");
}

function offFunction() {
    console.log("Your browser is working offline.");
}
</script>

</body>
</html>

Related Tutorials