首頁  >  文章  >  web前端  >  當瀏覽器開始離線工作時,在HTML中執行腳本?

當瀏覽器開始離線工作時,在HTML中執行腳本?

王林
王林轉載
2023-09-03 23:17:06526瀏覽

當瀏覽器開始離線工作時,在HTML中執行腳本?

當網頁瀏覽器開始離線工作時,onoffline 屬性就會觸發。您可以嘗試執行以下程式碼來實作onoffline 屬性 -

#範例

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

以上是當瀏覽器開始離線工作時,在HTML中執行腳本?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除