Javascript jquerymobile会话超时,有2个计时器

Javascript jquerymobile会话超时,有2个计时器,javascript,jquery-mobile,timeout,Javascript,Jquery Mobile,Timeout,编辑:我发现问题在于使用live而不是on。我修正了,但是,无法启动第二个计时器 错误:Object[对象对象]没有方法“弹出” 我正在尝试使用jquery mobile实现客户端会话超时。我的密码是: 感谢您的任何见解 为方便起见,代码如下: <!DOCTYPE html> <html> <head> <title>My Page</title> <meta name="viewport" content=

编辑:我发现问题在于使用live而不是on。我修正了,但是,无法启动第二个计时器

错误:
Object[对象对象]没有方法“弹出”

我正在尝试使用jquery mobile实现客户端会话超时。我的密码是:

感谢您的任何见解

为方便起见,代码如下:

<!DOCTYPE html>
<html> 
<head> 
    <title>My Page</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>


<!-- Application specific -->

<script> 
var first_timer = 2 * 1000;
var second_timer = 3 * 1000;
var down = -1;

function initTimer() {
  down = setTimeout(processTimeout, first_timer)
}

function processTimeout() {
        down = setTimeout(logout, second_timer);
        $.mobile.changePage('#timeout1',{transition:'slide', role:'dialog'});
        //alert ("Timeout of first timer, timerid:" + down );
}

function logout() {
    $("#timeout").popup('close');
  $.mobile.changePage('#timeout2',{transition:'slide', role:'dialog'});
  alert("You are logged out");
//  window.location = "http://www.google.com"
}

function resetMyTimer() {
  if ( -1 != down )
    clearTimeout(down);
  alert("Restarting timer");
  initTimer();
}

$("#loadingpage").on(function() {
    resetMyTimer();
});

initTimer();

</script>

</head>
<body>
<div data-role="page" id="loadingpage">
  <div data-role="header" data-position="fixed"> 
      <div class="headerlogo"> </div>
      <h1> Test </h1>
  </div> 
  <div data-role="content" >
    <div id="ssagov"> 
    <h1> Hi there </h1>
    </div> 
    <input type="button" data-shadow="false" data-corners="false" value="Next"  />
  </div><!-- /content --> 
</div><!-- /launch page -->
<div data-role="page" id="timeout1" data-role="popup">
  <div data-role="header" data-backbtn="false">
    <h1>Timeout1</h1>
  </div>
  <div data-role="content">
    Your session will timeout in 2 mins.
  </div>
</div>
<div data-role="page" id="timeout2" data-role="popup">
  <div data-role="header" data-backbtn="false">
    <h1>Timeout2</h1>
  </div>
  <div data-role="content">
    Your session has timed out
  </div>
</div>

</body>
</html>​

我的页面
var first_定时器=2*1000;
var秒定时器=3*1000;
var-down=-1;
函数initTimer(){
向下=设置超时(进程超时,第一个计时器)
}
函数processTimeout(){
向下=设置超时(注销,第二个计时器);
$.mobile.changePage('timeout1',{转换:'slide',角色:'dialog'});
//警报(“第一个计时器超时,timerid:+下降”);
}
函数注销(){
$(“#超时”)。弹出(“关闭”);
$.mobile.changePage('timeout2',{转换:'slide',角色:'dialog'});
警报(“您已注销”);
//window.location=”http://www.google.com"
}
函数resetMyTimer(){
如果(-1!=向下)
清除超时(向下);
警报(“重启计时器”);
initTimer();
}
$(“#加载页面”)。在(函数()上{
resetMyTimer();
});
initTimer();
试验
你好
超时1
您的会话将在2分钟后超时。
超时2
您的会话已超时
​

最后我解决了这个问题,我应该使用对话框而不是弹出窗口。以下是工作版本:

hmm,看起来我应该使用“on”而不是“live”。。