如何在不使用任何插件的情况下在普通jQuery中编写sessionTimeOut功能?我想使用我自己的警告ui.要弄清楚我可以写的任何UI活动,但不知道如何在超时功能中将它组合.
$('*').on('click', function () {
console.log('click', this);
});
$('*').on('change', function() {
console.log('change', this);
});
Run Code Online (Sandbox Code Playgroud)
您可以在所有现代浏览器上捕获mousemove事件:
(function () {
var timeoutSession;
document.addEventListener('mousemove', function (e) {
clearTimeout(timeoutSession);
timeoutSession = setTimeout(function () {
alert('Make SESSION expire');
//call a script here to server...
}, 30000); //30s
}, true);
})();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3774 次 |
| 最近记录: |