问题描述
在页面加载,我开始一个计时器,以检查是否会话已过期。我通过Ajax调用页面到期检查。我需要到期之前警报显示5分钟重定向期满后默认页面。这里是我的code:
On page load, I am starting a timer to check if session is expired. I am checking expiry by making ajax call to a page. I need to display alert 5 minutes before expiry and redirect to default page after expiry. Here is my code:
function startSessionCheckTimer() {
setInterval(checkSessionExpiry, 60000);
}
function checkSessionExpiry() {
$.ajax({
type: "POST",
url: "/Default.aspx/IsSessionOpen",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (time) {
if (time.d == 5) {
//alert("Your session will expire in 5 minutes.");
setTimeout(function () { alert('Your session will expire in 5 minutes.'); }, 100);
}
else if (time.d <= 0) {
window.location = "/Default.aspx";
}
}
});
}
显示5分钟后
警报,但如果用户不点击OK,它会阻止javascript和没有进一步的Ajax调用的。
Alert is displayed after 5 minutes, but if user does not click OK, it blocks the javascript and no further ajax calls are made.
有没有办法,我可以不阻止它显示警报的方法吗?
我不想使用jQuery对话框。
Is there a way that I can display Alert without blocking it?I do not want to using jQuery dialog.
推荐答案
没有,有没有办法不停止脚本的执行,显示本地警报。
No, there is no way to display a native alert without halting the execution of the script.
的唯一方法是使用一个对话框或东西是不是原生警觉
The only way is to use a dialog or something that is not a native alert
这篇关于显示JavaScript警告,而不拦截JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!