を働いていないnullに変数を設定(onBlur()
とonFocus()
を参照)関数は、まだcheckForChangesSupport()
を参照してください(同じのsetIntervalでgetTableSupport.phpをロードしています。機能onBlurイベントが設定されている場合は、すべての5000ms私はonFocus
が再び呼び出されるまで、いずれかの方法は、supportchatinterval
がちょうど整数である。てclearIntervalと下の私のコードで<code>supportchatinterval = null;</code>と<code>clearInterval(supportchatinterval);</code>を持つにもかかわらず
<script>
supportchatinterval = 5000;
$(document).ready(function(){
checkForChangesSupport();
setTimeout(checkForChangesSupport, supportchatinterval);
});
function checkForChangesSupport() {
$.get("getCountSupport.php", function(response) {
if(response == 1) {
refreshTableSupport();
}
setTimeout(checkForChangesSupport, supportchatinterval)
});
}
function refreshTableSupport(){
$('#tableHolderSupport').load('getTableSupport.php');
}
</script>
<script type="text/javascript">
function onBlur(){
document.body.className = 'blurred';
$.get("afk.php?afk=1");
supportchatinterval = null;
clearInterval(supportchatinterval);
};
function onFocus() {
document.body.className = 'focused';
$.get("afk.php?afk=0");
supportchatinterval = 5000;
refreshTableSupport();
}
</script>
1)あなたがしています'setTimeout'と' setInterval'を混在させます。 2) 'setTimeout'はタイムアウトIDを返します。 – gcampbell
ありがとう私は明らかに盲目です – michelle
PHPはこの質問とは関係ありません、タグを削除してください:) –