How many minutes:seconds are passed betweek the visit and the exit?
I have to develop a very small JS script that saves the time spent between "entry" and "exit" 开发者_如何学Con a page. This script has to monitor the user when he
"enters on the page"
and when
"he exits." (read "exit" as closing the page or closing the browser)
Is it possible? I can use:
www.example.com/enter.php
(requested when the user enters the page)
and
www.example.com/exit.php
(requested when the users exits the page)
I have to save data to calculate how many minutes:seconds
pass for each unique visit. (like Google Analitycs).
Using jQuery (example):
<script type=”text/javascript”>
var start = new Date().getTime();
$(window).unload(function() {
var total = new Date().getTime() - start;
alert(total);
// Ajax total back to server
});
</script>
精彩评论