Execute a script when the browser starts to work offline in HTML?

HTMLWeb DevelopmentFront End Technology

When the web browser starts to work offline, the onoffline attribute triggers. You can try to run the following code to implement onoffline attribute −

Example

<!DOCTYPE html>
<html>
   <body ononline = "onlineFunc()" onoffline = "offlineFunc()">
      <script>
         function onlineFunc() {
            alert ("Working online!");
         }
         function offlineFunc() {
            alert ("Workinf offline!");
         }
      </script>
      <p>Got o the web browser menu bar and click the File menu. Select "Work Offline" and toggle between online and offline.</p>
   </body>
</html>
raja
Published on 14-Mar-2018 07:08:28
Advertisements