如何使网站每30秒自动返回首页?

我正在设计一个将在医院大厅中显示的网站,该网站在触摸屏上操作,以获取一般信息。有人停止使用后,我们需要自动返回首页。

最佳答案

看看Paul Irish和idletimer的这个不错的jQuery demo here插件

基本上,它将在指定的空闲时间之后触发一个回调函数,您可以在其中将其转发回主页。

用法:

// idleTimer() takes an optional argument that defines the idle timeout
// timeout is in milliseconds; defaults to 30000
$.idleTimer(10000);

$(document).bind("idle.idleTimer", function(){
 // function you want to fire when the user goes idle
});

$(document).bind("active.idleTimer", function(){
 // function you want to fire when the user becomes active again
});

// pass the string 'destroy' to stop the timer
$.idleTimer('destroy');


请注意以下事件:'mousemove keydown DOMMouseScroll mousewheel mousedown touchstart touchmove'From source code

关于jquery - 每30秒自动返回首页,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10128226/

10-10 00:13