Horje
HTML onoffline Attribute

Definition and Usage

The onoffline attribute fires when the browser starts to work offline.

Tip: The onoffline attribute is the opposite of the ononline attribute.


Applies to

The onoffline attribute is part of the Event Attributes, and can be used on the following element:

Elements Event
<body> onoffline

How to Execute a JavaScript when the browser starts to work offline - HTML onoffline 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 offline - HTML onoffline Attribute




html onoffline attribute

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


Read Article
https://develop.horje.com/learn/1434/reference