Fork me on github

页签刷新,关闭

1、页签关闭

        window.onunload = () => {
        console.log('关闭只调用一个方法=================================');
        }//验证:关闭之后触发, 页面刷新2

2.页签刷新

      window.onbeforeunload = () => {
            console.log('刷新时先调用此方法,页面刷新1=================================');
        }
        window.onunload = () => {
                  console.log('在调用此方法,页面刷新2=================================');
        }//验证:关闭之后触发, 页面刷新2

 

posted @ 2022-01-06 12:07  我の前端日记  阅读(124)  评论(0编辑  收藏  举报
Copyright © 2021 LinCangHai
Powered by .NET 5.0 on Kubernetes