如何在会话即将在弹出窗口中过期时向用户显示消息 [英] how to show message to user when session is about to expire in popup

查看:70
本文介绍了如何在会话即将在弹出窗口中过期时向用户显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在会话即将到期时向用户显示弹出窗口并在用户点击确定时重定向到用户...怎么做?... plz help ...

i want to show popup to user when session is about to expire and redirect to user when he clicks ok...how to do it?...plz help...

推荐答案

Hai

只需使用aleart消息显示时间到期,试试这个,请在​​MVC4中添加此javascript查看MasterPage,然后只有它可以在所有子页面上工作,你可以在每个页面也是如此,但是母版页是常见的,所以最好添加到母版页。这里等待15分钟,你可以改变你的到期时间



Hai
Just use aleart message to show time expiry,Try this,pls add this javascript in MVC4 View MasterPage,then only it work all child page,u can add this in each page also,but master page is common so better to add in master page.Here time wait for 15 mins,u can change ur expiry time

<script type="text/javascript">



               var logoutUser = false;
               var timeoutHnd = null;
               var logouTimeInterval = 15 * 60 * 1000; // 15 mins
               function onuser_activite() {
                   if (logoutUser) {
                       ;
                   }
                   else {
                       ResetLogOutTimer();

                   }
               }
               function OnTimeoutReached() {
                   logoutUser = true;
                   alert("You have been automatically Log Off from the system !");
                   window.location.href = "Logout.aspx";

               }
               function ResetLogOutTimer() {
                   clearTimeout(timeoutHnd);
                   // set new timer
                   timeoutHnd = setTimeout('OnTimeoutReached();', logouTimeInterval);
               }


               document.body.onclick = onuser_activite;
               timeoutHnd = setTimeout('OnTimeoutReached();', logouTimeInterval);
           </script>


这篇关于如何在会话即将在弹出窗口中过期时向用户显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆