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 −


<!DOCTYPE html>
   <body ononline = "onlineFunc()" onoffline = "offlineFunc()">
         function onlineFunc() {
            alert ("Working online!");
         function offlineFunc() {
            alert ("Workinf offline!");
      <p>Got o the web browser menu bar and click the File menu. Select
      "Work Offline" and toggle between online and offline.</p>
Updated on 03-Mar-2020 07:36:24