2

編集:問題は、オンではなくライブを使用することにあると思います。私はそれを修正しましたが、2番目のタイマーを起動させることができません。

エラー:Object [object Object] has no method "popup"

jquerymobileを使用してクライアント側のセッションタイムアウトを実装しようとしています。私のコードは次の場所にあります:http://jsfiddle.net/83BSW/5

洞察に感謝します。

便宜上、コードは次のとおりです。

<!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>​
4

1 に答える 1

1

最後に、ポップアップの代わりにダイアログを使用する必要がある問題を修正しました。ここに作業バージョンがあります: http://jsfiddle.net/83BSW/6

于 2012-07-13T17:06:42.927 に答える