闲置5分钟后如何更改页面位置

编程入门 行业动态 更新时间:2024-10-22 23:04:22
本文介绍了闲置5分钟后如何更改页面位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I want that if there is no activity on my page for 5 mins then the page will be redirected to a predefined page.

任何人都可以建议我如何使用JavaScript或jQuery.

Can anyone suggest me how to do this using JavaScript or jQuery.

推荐答案

如果您想要一个真正的非活动控件,请使用此库(该控件也可以控制鼠标和键盘活动) )

If you want a real inactivity control please use this library (which control mouse and keyboard activity too)

jQuery空闲计时器

The jQuery idletimer

paulirish/2009/jquery-idletimer-plugin/

这里是使用示例:

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

更多推荐

闲置5分钟后如何更改页面位置

本文发布于:2023-11-27 03:17:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636345.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何更改   位置   页面   分钟后

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!