0
私はシステムを使ってユーザーの活動を追跡しています。 Google Chromeの魅力のように機能しますが、FirefoxやSafari(window.closeによるものと思われます)では動作しません。なぜなら、dbに 'end_start'を書き込まず、ページの結果がまだ開いているからです。 .jsファイルXMLHttpRequestの追跡に関する問題(FirefoxとSafariの場合のみ)
function start(pageName) {
var xmlhttp3;
if (window.XMLHttpRequest) {
xmlhttp3 = new XMLHttpRequest();
} else {
xmlhttp3 = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp3.onreadystatechange=function() {
if (xmlhttp3.readyState==4 && xmlhttp3.status==200) {
}
}
xmlhttp3.open("GET","includes/trackStart.php?pageName="+pageName,true);
xmlhttp3.send();
}
function end() {
var xmlhttp3;
if (window.XMLHttpRequest) {
xmlhttp3 = new XMLHttpRequest();
} else {
xmlhttp3 = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp3.onreadystatechange=function() {
if (xmlhttp3.readyState==4 && xmlhttp3.status==200) {
}
}
xmlhttp3.open("GET","includes/trackEnd.php",true);
xmlhttp3.send();
}
HTML
<script src="../includes/jsHandler.js"></script>
<script>
window.onload = function(){ return start('<?php echo basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['PATH_INFO']); ?>');};
window.onbeforeunload = function(){ return end(); };
window.onclose = function(){ return end(); };
</script>
ありがとうございました!