用户在网页的逗留时间
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); }