![]() |
Definition and UsageThe onoffline attribute fires when the browser's connection status changes from online to offline. Tip: The onoffline attribute is the opposite of the ononline attribute. Browser SupportThe numbers in the table specify the first browser version that fully supports the event attribute. Syntax
Attribute Values
Technical Details
|
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>
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>
html event attributes |
HTML onafterprint Event Attribute | Window Event Attributes |
HTML onbeforeprint Event Attribute | Window Event Attributes |
HTML onbeforeunload Event Attribute | Window Event Attributes |
HTML onerror Event Attribute | Window Event Attributes |
HTML onhashchange Event Attribute | Window Event Attributes |
HTML onload Event Attribute | Window Event Attributes |
HTML onoffline Event Attribute | Window Event Attributes |
HTML ononline Event Attribute | Window Event Attributes |
HTML onpageshow Event Attribute | Window Event Attributes |
HTML onresize Event Attribute | Window Event Attributes |
HTML onunload Event Attribute | Window Event Attributes |
How to add a JavaScript when the browser changes from working online to working offline | Window Event Attributes |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | Window Event Attributes |
Uploaded by: | Admin |
Reffered: https://www.w3schools.com/tags/ev_onoffline.asp