开发者

How many minutes:seconds are passed betweek the visit and the exit?

开发者 https://www.devze.com 2023-03-11 07:23 出处:网络
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

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消