хорошо, я опубликовал «раздражающий всплывающий» вопрос, в качестве решения для «регистрации» чьего-то времени, проведенного на странице, общий консенсус заключался в том, чтобы использовать вызов ajax для таймера, чтобы сообщить серверу, что пользователь был все еще на странице ... (ниже приведен код, который я использую).
одна проблема, которую я имею, это то, что httRequest, похоже, кешируется ... при каждом возврате отображается та же "отметка времени" ...
<script type="text/javascript">
var closeMe = 0;
var logMe = 0;
//the window doesn't have focus, do nothing or something that let's them know we're not logging at the moment
function onBlur() {
///stop the log interval
clearInterval ( logMe );
//after 2 min of non focus, close it.
closeMe = setInterval('window.close()',120000); //after 2 min of non focus, close it.
}
//the window has focus... keep logging.
function onFocus(){
//stop the close counter - in the event to 'blurred' sometime
clearInterval ( closeMe );
//run the AJAX on a schedule - we're doing it every minute - bu tyou can do it as often as you like
logMe = setInterval('logTime()',60000);
}
//call a script that logs another minute...
function logTime() {
var xhReq = new XMLHttpRequest();
xhReq.open("GET", "ajax-on-time-interval.cfm", false);
xhReq.send(null);
var serverResponse = xhReq.responseText;
alert(serverResponse);
}
// check for Internet Explorer... IE uses 'onfocusin/out" - everything else uses "onfocus/blur"
if (/*@cc_on!@*/false) {
document.onfocusin = onFocus;
document.onfocusout = onBlur;
} else {
window.onfocus = onFocus;
window.onblur = onBlur;
}
</script>
Код для "ajax-on-time-interval.cfm"
# Теперь () #