【发布时间】:2016-09-22 12:55:36
【问题描述】:
请帮助我。我必须找到用户在页面上完成活动的总时间,如鼠标移动、按键等。我想获得该页面被使用的有用时间。 我已经编写了一些代码来计算页面打开的总时间以及用户关注该页面的时间。
计算此有用时间的另一种方法是计算页面上的总空闲时间,对此没有进行任何操作(我的意思是鼠标移动、按键)。 有用时间=总页面打开时间-总空闲时间
请帮忙 这是代码。
var start, end, openingtime, pagefocustime = 0;
$(document).ready(function(){
start = performance.now();
$(window).on('blur', function() {
end = performance.now();
pagefocustime += end - start
})
$(window).on('focus', function() {
start = performance.now();
})
$(window).on('beforeunload',function(){
end = performance.now();
pagefocustime += end - start
console.log("Exact Page Focused Time : ");
console.log(pagefocustime);
openingtime = end-start;
console.log("Total Page Read Time : "+ openingtime);
});
});
请帮忙。 提前致谢。
【问题讨论】:
标签: javascript jquery html angularjs