當瀏覽器開始線上工作時在 HTML 中執行指令碼?


當 Web 瀏覽器開始線上工作時,ononline 觸發屬性。您可以嘗試執行以下程式碼來實現ononline 屬性 −

示例

<!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>

更新時間: 2020 年 3 月 3 日

96 次瀏覽

開啟您的職業生涯

完成課程,獲得認證

開始吧
廣告
© . All rights reserved.