JS Countdown to achieve results, and exit the system

BACKGROUND: After a single sign-on, has been operating in this system, but the portal decency session expiration time is 30 minutes, so 30 minutes later, the need to re-login systems before they can operate.

Methods: In this thought each operating system are to begin with portal system interact channels refreshToken, but feel any operations to request refreshToken, the system will cause problems, so just write a JS to deal with the problem .

<HTML> 
<head> 
<Meta HTTP-equiv = " the Content-the Type " Content = " text / HTML; charset = UTF-. 8 " /> 
<title> Js achieved countdown effect </ title> 
<Script Language = " JavaScript " > var timeLeft = . 1 * . 3 * 1000 ; // this set time is 90 seconds function countTime () { 
     IF (timeLeft == 0 ) { // operation after time, this is to be executed, and here just bounced an alert box var msg = " portal session expires, you need to log in again, make sure? " ; 
            if



        (Confirm (MSG) == to true ) { 
                var LogoutURL = " ./oauthLogout.do " ; 
               window.location.replace (LogoutURL); // page refresh 
               return ; 
            } the else { 
               timeLeft = . 1 * . 3 * 1000 ; // here set time is 90 seconds 
            } 
    } 
    var startMinutes = the parseInt (timeLeft / ( 60 * 1000 ), 10 ); 
     var startSec = the parseInt ((timeLeft - startMinutes *60 * 1000)/1000); 
    document.getElementById('show').innerHTML = "剩余时间:" + startMinutes + "分钟" + startSec + ""; 
    timeLeft = timeLeft - 1000; 
    setTimeout('countTime()',1000); 
} 

</script> 
</head> 

<body onload="countTime()"> 
<div id="show"></div> 
</body> 
</html>

These are examples according to the situation, slight modifications can solve the problem.

If this article helpful to you, please feel free to look a reward as an incentive, I will continue to work in! ! !

Guess you like

Origin www.cnblogs.com/zhangliang88/p/11275609.html