window.onunload = function (){

        differTime = new Date().getTime() - beginTime;

        if(differTime <= 5) {

            console.log("浏览器关闭")

        }else{

            console.log("浏览器刷新")

        }


    }

    window.onbeforeunload = function (){

       beginTime = new Date().getTime();

    };

---------------------

作者:微行

来源:CSDN

原文:https://blog.csdn.net/itlsq/article/details/81095323

版权声明:本文为博主原创文章,转载请附上博文链接!

Created with the Personal Edition of HelpNDoc: Free EBook and documentation generator