如何记录打开的html页面时间和关闭页面时间并存储在txt,csv文件中

时间:2015-05-31 04:32:09

标签: javascript php html5

我想记录网页打开和关闭的日期和时间。将数据存储在txt文件中,例如:开始日期时间,结束日期时间

<script type="text/javascript">
var startTime = new Date();        //Start the clock!
window.onbeforeunload = function()        //When the user leaves the page(closes the window/tab, clicks a link)...
{
    var endTime = new Date();        //Get the current time.
    var timeSpent=(endTime - startTime);        //Find out how long it's been.
    alert(timeSpent);        //Pop up a window with the time spent in microseconds.
}

0 个答案:

没有答案