html里的swal添加倒计时,使用甜蜜警报插件的setInterval函数倒计时
我試圖實現倒計時到sweetAlert。在不活動20分鐘后,會彈出甜蜜警報并顯示會話即將超時,并且用戶有兩種選擇:注銷或繼續,這將重新啟動空閑計時器。當鼠標移動或點擊時,空閑計時器也會重置。我的問題是,我希望在自動注銷之前在60-0(秒)內在sweetAlert標題的范圍(title: "Teie sessioon on aegumas sekundi p?rast!",)中顯示倒計時。 我嘗試了所有的方法,但沒有奏效。倒計時顯示,但沒有重新啟動。使用甜蜜警報插件的setInterval函數倒計時
任何幫助,將不勝感激。
$(document).ready(function() {
var idleTime = 0;
//Zero the idle timer on mouse movement
function timerIncrement() {
idleTime ++;
if (idleTime >= 5) { // For testing 5 seconds else 20 minutes
swal({
html: true,
title: "Teie sessioon on aegumas sekundi p?rast!",
text: "Sessiooni pikendamiseks vajutage nuppu J?tka, v?lja logimiseks vajutage V?lju." ,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "J?tka",
cancelButtonText: "V?lju",
timer: 60000, //3600
closeOnConfirm: false,
closeOnCancel: false }, function(isConfirm){
if (isConfirm) {
swal("J?tkatud!",
"Teie sessiooni pikendati 1 tunni v?rra.",
"success");
} else {
swal("V?ljutud",
"Teid suunatakse tagasi sisselogimis lehele",
"error"),
location.href = "logout.php?logout=true";
}
});
}
}
//Increment the idle time counter every minute.
var idleInterval = setInterval(timerIncrement, 1000); // 1 minute
$(this).mousemove(function (e) {
idleTime = 0;
});
$(this).keypress(function (e) {
idleTime = 0;
}
2016-03-01
raqulka
+0
做你找到答案了嗎? –
+0
@khakiout no sir。仍在試圖弄清楚。有任何想法嗎? –
總結
以上是生活随笔為你收集整理的html里的swal添加倒计时,使用甜蜜警报插件的setInterval函数倒计时的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 我打不过电王的合金战神,求大神帮助
- 下一篇: 求一个好听的赵姓女孩名字。