I want to record time spent on webpages. Is there an appropriate JQu开发者_C百科ery plugin written for this? I could then record the value of the timer in a variable and insert to a database.
JJH
Google Analytics is a great solution for this. A better, faster wheel has already been invented.
If you're hell bent on this feature it's quite easy:
var interVal = 60000; // 60 seconds (adjustable)
var totalTime = 0;
function LogTime() {
totalTime += interVal;
$.ajax { /* Your ajax call to tell the server totalTime */ }
setTimeout("LogTime()", interVal);
}
setTimeout("LogTime()", interVal);
But Diodeus is probably right, there are better ways to get this metric.
精彩评论