如果没有动作,如何在20分钟内重定向页面 [英] How to redirect the page in 20min if no actitvity happens on it

查看:65
本文介绍了如果没有动作,如何在20分钟内重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个娱乐网站,如果用户没有对其执行任何操作,我可以从用户端发生如何重定向页面或使其在20分钟后自动注销的活动。



有没有可以实现的功能?

解决方案

1997年,我不得不建立一个基于信息亭的网络应用程序超时并返回主页。我在< HEAD>中使用了META标签。像这样:



< META HTTP-EQUIV =刷新CONTENT =1200; URL = http://mywebsite.com/index.html>


jquery-idletimer-plugin / [ ^ ]



希望它能帮到你..


你可以使用javascript setTimeout在20分钟后调用一个函数,你可以编写如下代码。 20000表示20分钟,它将以毫秒为单位。或者你可以使用javascript

setInterval在20分钟后调用一个函数。您可以在jquery的document.ready函数中添加此setinterval和settimeout函数,或者您可以在任何地方使用它。



setTimeout(MethodToCall(),20000); < br $>


window.setInterval(MethodToCall,20000);



函数MethodToCall()

{

...

//

..

}



并查看以下格式时间



  var  delay =  30 ;  //   
var userTimeExpired;
var IDLE_TIMEOUT = 30 ; //
var idleSeconds = 0 ;
document.onclick = function(){
idleSeconds = 0 ;
};
document.onmousemove = function(){
idleSeconds = 0 ;
};
document.onkeypress = function(){
idleSeconds = 0 ;
};
window.setInterval(CheckIdleTime, 1000 );

函数CheckIdleTime(){

_idleSecondsCounter ++;
var popUpPanel = document.getElementById( scanCardchild);
if (idleSeconds > = IDLE_TIMEOUT){
// 此处回发到新页面
}
}


Am developing an entertainment site and it no activity happens from the user side how i can redirect the page or make it automatically logout after 20min if user is not performing any kind of action on it .

Is there any function that can make it happens?

解决方案

In 1997, I had to build a kiosk-based web application that would timeout and go back to the home page. I used a META tag within <HEAD> like this:

<META HTTP-EQUIV="Refresh" CONTENT="1200; URL=http://mywebsite.com/index.html">


jquery-idletimer-plugin/[^]

Hope it will help you..


You can use javascript setTimeout for calling a function after 20 min and you can write your code like the following. 20000 means 20 minutes and it will be in millisecond. Or you can use javascript
setInterval for calling a function after 20 min. You can add this setinterval and settimeout function in document.ready function of jquery or yoou can use it anywhere.

setTimeout("MethodToCall()", 20000);

window.setInterval(MethodToCall, 20000);

function MethodToCall()
{
...
//
..
}

And check the idele time like the following

var delay = 30; //seconds
    var userTimeExpired;
    var IDLE_TIMEOUT = 30; //seconds
    var idleSeconds = 0;
    document.onclick = function () {
        idleSeconds = 0;
    };
    document.onmousemove = function () {
        idleSeconds = 0;
    };
    document.onkeypress = function () {
        idleSeconds = 0;
    };
    window.setInterval(CheckIdleTime, 1000);

    function CheckIdleTime() {

        _idleSecondsCounter++;
        var popUpPanel = document.getElementById("scanCardchild");
        if (idleSeconds >= IDLE_TIMEOUT) {
           //Postback to new page here
        }
    }


这篇关于如果没有动作,如何在20分钟内重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆