javascript - 当其中一个选项卡中有活动时,使所有选项卡的会话保持活动状态
问题描述
当我在浏览器中打开了几个选项卡并且其中一个选项卡处于不活动状态时,尽管其他选项卡有活动,但所有选项卡的会话都将关闭。
我在 _layout.cshtml 中找到的代码如下:
<script>
var inactivityTime = function () {
var timeForCloseSession= '@Configuration.GetSection("Time")["Logout"]';
var timeForOpenModalWarning = '@Configuration.GetSection("Time")["WarningModal"]';
var time;
window.onload = resetTimer;
document.onmousemove = resetTimer;
document.onkeypress = resetTimer;
function logout() {
$('#userInactive').modal('show');
// We remove the user from the session
setTimeout(closeSession, timeForCloseSession)
};
function closeSession() {
if (!$('#userInactive').hasClass('show')) {
// We do not close session if the modal is closed
return false;
} else {
location.href = '/Login/Logout';
}
};
function resetTimer() {
clearTimeout(time);
time = setTimeout(logout, timeForOpenModalWarning)
}
};
window.onload = function () {
console.log("We load the inactivity module");
inactivityTime();
}
</script>
如果其中任何一个选项卡有活动,我希望能够使所有选项卡的会话保持活动状态非常感谢!
解决方案
推荐阅读
- openmp - 使用 OpenMP 并行化 Cython 中的问题
- python - 将浮点值舍入到间隔限制/网格
- javascript - 正则表达式在数组中查找对
- sql - 从表有 > 0 行的 all_tab_columns 中选择
- javascript - 动态参考
- cron - crontab 文件中的错误
- android - 是否可以将子集合添加到集合而不在 android 的 firestore 中创建文档?
- android - Unity 4.5:让角色开始触摸触发的动画
- javascript - 如何翻译 A-Frame 动态体
- android - 让 RecyclerView 自动加载第 1 页