你好下, 找不到代码:x有人可以发帖,或解释如何在10分钟无效后制作弹出窗口?
当页面加载后10分钟内成员处于非活动状态时,成员将获得带有一些按钮和文本的弹出窗口
- for each object:
- create object with category and color
- push group values into object
- if 2nd group, create 2nd obj, push group
- result: a whole bunch of objects, each with category/color/side/group_id
- get all objects with group_id
- ?? find unique keys, to iterate through?
- ?? iterate & check if key matches existing in array, increase count?
答案 0 :(得分:1)
var seconds = 0;
var timeoutCounter = setInterval(function(){
seconds++;
if(sec == 600) {
// do stuff to launch popup
clearInterval(timeoutCounter);
}
}, 1000);
$(document).mousemove(function (e) {
clearInterval(timeoutCounter);
seconds = 0;
setInterval(timeoutCounter);
});
$(document).keypress(function (e) {
clearInterval(timeoutCounter);
seconds = 0;
setInterval(timeoutCounter);
});
这基本上每秒运行一次 - 如果是第600秒,则在运行代码后退出。
答案 1 :(得分:0)
将事件与setTimeout
方法一起附加到var popupTimer,
TIME_OUT = 600;
// function that displays the popup
function displayPopup() {
// display the popup here
}
// Set the timeout to display the popup
popupTimer = setTimeout(displayPopup, TIME_OUT);
// attch events to the document object
// you can add more events here based on
// what events you want to track
$(document).on('click change keypress', function() {
// clear the timeout whenever the event is handled
clearTimeout(popupTimer);
// Reset the timer
popupTimer = setTimeout(displayPopup, TIME_OUT);
});
方法以显示弹出窗口。一种方法是
public function getConfig()
{
return include __DIR__ . '\config\module.config.php';
}