jQuery技术:如何在不活动5分钟后更改页面位置

我希望如果我的页面上没有活动5分钟,那么页面将被重定向到预定义的页面。

谁能建议我如何使用JavaScript或jQuery做到这一点。

    如果你想要一个真正的不活动控件,请使用这个库(它也控制鼠标键盘活动)

    jQuery idletimer

    以下是它的一个示例用法:

     // 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'); 

    可能与此类似的东西?

       

    嗨,请查看此博客文章,了解如何检测网站中的空闲用户。 它是一个jQuery Idletimer插件 。 你可以在这里找到演示页面 。

    简单用法:

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

    你从github获得jQuery Idletimer插件的源代码

    难道你不能只将META刷新设置为超时所需的秒数并指向相应的重定向页面吗?

      

    我知道这通常是不受欢迎的,但它避免了对jQuery(或Javascript,就此而言)的需要,并且所有浏览器都尊重它。

    有时简单就更好了,即使它很难看。

      以上就是jQuery教程分享如何在不活动5分钟后更改页面位置相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/jquerytutorial/562035.html

      (0)
      上一篇 2021年2月5日
      下一篇 2021年2月5日

      精彩推荐