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