HTML onoffline Event Attribute
Description
The onoffline HTML event attribute triggers when the browser starts to work offline. This can happen for a variety of reasons, such as the user disconnecting from the internet or the network being unavailable.
The onoffline event attribute can be used to notify the user that the browser is offline and to take appropriate action. For example, a website could use the onoffline event attribute to display a message to the user informing them that they are offline and that certain features may not be available. The website could also use the onoffline event attribute to disable certain features, such as online forms or video streaming.
The onoffline event attribute is only supported by the <body> tag.
Here is an example of how to use the onoffline event attribute:
<body onoffline="alert('You are now offline.')">
</body>
When the browser goes offline, an alert message will be displayed to the user.
It is important to note that the onoffline event attribute does not guarantee that the browser will be completely offline. It is possible that the browser may still be able to access certain resources, such as cached files or local storage. However, the onoffline event attribute can be used to take precautionary measures to ensure that the user has a good experience even when the browser is offline.
Syntax
<element onoffline="script">
Values
- scriptThe name of the script to use when the event has been triggered.
Example
Browser Support
The following information will show you the current browser support for the HTML onoffline event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.
This event attribute is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 14th October 2023
