Tutorialspoint

       

Tutorialspoint

   

首頁  >  文章  >  web前端  >  在HTML中,當頁面卸載時執行腳本?

在HTML中,當頁面卸載時執行腳本?

WBOY
WBOY轉載
2023-09-04 18:57:061325瀏覽

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

以上是在HTML中,當頁面卸載時執行腳本?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

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