A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-onoffline-event-attribute/ below:

HTML onoffline Event Attribute - GeeksforGeeks

HTML onoffline Event Attribute

Last Updated : 11 Jul, 2025

The onoffline event attribute works when the browser works in offline mode. It is the opposite of ononline event attribute. It is activated when the device loses its internet connection. It is also useful for adapting the web application's behavior when network connectivity is lost.

Note: The `onoffline` attribute is a direct opposite of the `ononline` attribute.

Syntax
<element onoffline = "script">
Attribute Value

The script event is run when onoffline attribute is called.

Example: 

 In this example, we will see the implementation of the above tag.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>onoffline event attribute</title>
    <style>
        h1 {
            color:green;
        }
        body {
            text-align:center;
        }
    </style>
</head>

<body onoffline="gfg()">
    <h1>GeeksforGeeks</h1>
    <h2>onoffline Event Attribute</h2>
    <script>
        function gfg() {
            alert ("Browser working in offline mode");
        }
    </script>
</body>

</html>

Output: 

Example 2:  

In this example, we will see the implementation of the above tag.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>onoffline event attribute</title>
    <style>
        h1 {
            color: green;
        }

        body {
            text-align: center;
        }
    </style>
</head>

<body onoffline="gfg()">
    <h1>GeeksforGeeks</h1>
    <h2>onoffline Event Attribute</h2>
    <script>
        function gfg() {
            console.log("Browser working in offline mode");
        }
    </script>
</body>

</html>

Output:

Supported Tags  Supported Browsers

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4