当前位置: 代码迷 >> Web前端 >> 用户在网页的停留时间
  详细解决方案

用户在网页的停留时间

热度:248   发布时间:2013-08-14 14:27:55.0
用户在网页的逗留时间
  var second = 0;
        var minute = 0;
        var hour = 0;
        var time;
        window.setTimeout("staytime();", 1000);

        function staytime() {

            second++;

            if (second == 60) { second = 0; minute += 1; }

            if (minute == 60) { minute = 0; hour += 1; }

            window.onbeforeunload = function () {
                alert(time);
            }
            time = hour + "小时" + minute + "分" + second + "秒";
          
            window.setTimeout("staytime();", 1000);

        }

  相关解决方案