Horje
HTML ononline Event Attribute

Definition and Usage

The ononline attribute fires when the browser's connection status changes from offline to online.

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


Browsers Support of HTML ononline Event Attribute

The numbers in the table specify the first browser version that fully supports the event attribute.

Output should be:

Browsers Support of HTML ononline Event Attribute

Syntax of HTML ononline Event Attribute

<element ononline="script">

Attribute Values of HTML ononline Event Attribute

Value Description
script The script to be run on ononline

Technical Details of HTML ononline Event Attribute

Supported HTML tags: <body>

Example of HTML ononline Event Attribute

Execute a JavaScript when the browser changes from working offine to working online.

index.html
Example: HTML
 <body ononline="myFunction()"> 

Output should be:

Example of HTML ononline Event Attribute

How to add a JavaScript when the browser changes from working offine to working online

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 add a JavaScript when the browser changes from working offine to working online




html event attributes

Related Articles
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

Single Articles
Browsers Support of HTML ononline Event AttributeWindow Event Attributes
Syntax of HTML ononline Event AttributeWindow Event Attributes
Attribute Values of HTML ononline Event AttributeWindow Event Attributes
Technical Details of HTML ononline Event AttributeWindow Event Attributes
Example of HTML ononline Event AttributeWindow Event Attributes
How to add a JavaScript when the browser changes from working offine to working onlineWindow Event Attributes

Type:
Develop
Category:
Web Tutorial
Sub Category:
Window Event Attributes
Uploaded by:
Admin


Reffered: https://www.w3schools.com/tags/ev_ononline.asp