javascript - Time diff code is not working -
here want find total time spent user on page.
for using following code not working. using jquery1.8. please see it.
var entertime; var endtime; var difftime; $(document).ready(function (e) { entertime=e.timestamp; }); $(window).bind('beforeunload', function(f){ endtime=f.timestamp; difftime=endtime-entertime; alert(difftime); });
try using following:
var entertime; var endtime; var difftime; $(document).ready(function () { entertime=new date().gettime(); }); $(window).bind('beforeunload', function(){ endtime=new date().gettime(); difftime=endtime-entertime; });
please note cannot raise alert()
s before closing page in way described in original post.
Comments
Post a Comment