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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -