在 HTML 中,當頁面已解除安裝時執行指令碼?


unloaded 屬性在網頁已解除安裝時觸發。可以嘗試執行以下程式碼,在 HTML 中實現 unloaded 屬性 −

示例

<!DOCTYPE html>
<html>
   <body onunload = "display()">

      <h2>Tutorialspoint</h2>
      <h3>Simply Easy learning</h3>

      <script>
         function display() {
            alert("Bye!");
         }
      </script>

   </body>
</html>

更新於: 03-03-2020

110 瀏覽量

開啟您的職業生涯

完成課程後獲得認證

開始
廣告
© . All rights reserved.