Horje

How to Execute a JavaScript when the browser starts to work online - HTML ononline Attribute

Body Example. Try to disconnect from the internet to toggle between working online and offline.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body ononline="onFunction()" onoffline="offFunction()">

<p>Try to disconnect from the internet to toggle between working online and offline.</p>

<script>
function onFunction() {
  alert ("Your browser is working online.");
}

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

</body>
</html>

Output should be:

How to Execute a JavaScript when the browser starts to work online - HTML ononline Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin