HTML onoffline Attribute: The HTML onoffline attribute is defined as it fires when the browser starts to work offline. It is supported by <body> tag only. It is the opposite of ononline event attribute. HTML4 does not support the onoffline attribute. It was newly added to the HTML5 attribute.
HTML onoffline Attribute
The HTML onoffline attribute can be applied to the <body> element.
Syntax: <element onoffline = “script”>
Browser Support:
The HTML onoffline attribute is supported by the following browsers:
- Chrome- does not support
- Firefox-3.0
- Safari-does not support
- Opera-does not support
- Internet Explorer-8.0
Example: for <body> element
<!DOCTYPE html> <html> <body ononline="onFunction()" onoffline="offFunction()"> <p>Open the File menu and click on "Work Offline" 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: