function statisticsStay(){console.log(localStorage.getItem('testSecond'));var second = 0;//开启定时器记录页面停留时间var timer = setInterval(function(){second++;},1000);//页面刷新、关闭时触发onbeforeunload事件把停留时间记录到localStoragewindow.onbeforeunload = function(){localStorage.setItem('testSecond',second);};}statisticsStay();
第一句子网 - 唯美句子、句子迷、好句子大全