如何检测浏览器(chrome)窗口是刷新还是关闭?

时间:2017-09-27 11:47:00

标签: javascript

此代码工作正常但在IE中工作,我需要谷歌Chrome感谢。

    var isRefresh;
    function detectRefresh(){
     try
     {
       if(window.opener.title == undefined){
         isRefresh = true;
         document.write('Window was refreshed!');
       }
     }
     catch(err)
     {
       isRefresh = false;
       document.write('Window was closed!');
     } 
   }

0 个答案:

没有答案