php 怎麼時間觀察訪問者 停留頁面的時間

來源:互聯網
上載者:User
php 如何時間觀察訪問者 停留頁面的時間

當開啟頁面時,PHP記錄IP和訪問時間
關閉頁面時,做個onunload事件,這個事件就是給PHP發送關閉a.html的請求,這時候PHP做
關閉時間-訪問時間=停留時間

不包括一些特殊情況,如:斷電導致關閉瀏覽器、不支援JS等特殊情況。

-------
簡單寫一個,也沒經過測試,你自己試下吧

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>javascript</title><meta http-equiv="content-type" content="text/html;charset=utf-8"></head><body onunload="unOnlineTime()"><img src="online.php?action=online" style="display:none;" id="onlineImg" /><script language="javascript">function unOnlineTime(){//online.php頁面做判斷,如果是online就是訪問了,unonline就是退出訪問狀態,由onunload事件發送請求//當然也可以用AJAX做document.getElementById('onlineImg').src = 'online.php?action=unonline';}</script></body></html>

以上就是 php 怎麼時間觀察訪問者 停留頁面的時間 的內容,更多相關內容請關注topic.alibabacloud.com(www.php.cn)!

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.