瀏覽器開始在 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.