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

HTMLWeb DevelopmentFront End Technology

When the web browser starts to work online, the ononline attribute triggers. You can try to run the following code to implement ononline 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:56
Advertisements