私はここから JQuery idleTimeout プラグインを使用しています:
http://www.erichynds.com/examples/jquery-idle-timeout/example-mint.htm
コードに実装すると問題なく動作しましたが、ページを起動するたびに毎回5 回更新されるため、idleTimeout コードを削除して確認しました。そして、それはこの問題を与えていませんでした。
詳細を調べた後、コードの " " 行を削除またはコメントするとpollingInterval:2
、すべてが正常に機能し、更新の問題が解消され、タイムアウト機能が引き続き機能することがわかりました。
pollingInterval:2
誰かが実際に何をしているのかを理解するのを手伝ってもらえますか?
プラグインのコードは次のとおりです
JS:
<script type="text/javascript">
// setup the dialog
$("#dialog").dialog({
autoOpen: false,
modal: true,
width: 400,
height: 210,
closeOnEscape: false,
draggable: false,
resizable: false,
buttons: {
'Yes, Keep Working': function () {
$(this).dialog('close');
},
'No, Logoff': function () {
// fire whatever the configured onTimeout callback is.
// using .call(this) keeps the default behavior of "this" being the warning
// element (the dialog in this case) inside the callback.
$.idleTimeout.options.onTimeout.call(this);
}
}
});
// cache a reference to the countdown element so we don't have to query the DOM for it on each ping.
var $countdown = $("#dialog-countdown");
// start the idle timer plugin
$.idleTimeout('#dialog', 'div.ui-dialog-buttonpane button:first', {
idleAfter: 600,
pollingInterval: 2, //<--- THIS IS CAUSING ISSUE
serverResponseEquals: 'OK',
onTimeout: function () {
window.location = "/Home/Index/";
},
onIdle: function () {
$(this).dialog("open");
},
onCountdown: function (counter) {
$countdown.html(counter); // update the counter
}
});
</script>
それが生成するダイアログボックス、
<!-- Session Time Out Message box -->
<div id="dialog" title="Your session is about to expire!">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 50px 0;"></span>You will be logged off in <span id="dialog-countdown" style="font-weight: bold"></span>seconds. </p>
<p>Do you want to continue your session?</p>
</div>
追加する必要がある 2 つの Jquery は次のとおりです。
http://www.erichynds.com/examples/jquery-idle-timeout/src/jquery.idletimer.js
http://www.erichynds.com/examples/jquery-idle-timeout/src/jquery.idletimeout.js
他に必要な情報があれば教えてください!
提案してください!