【发布时间】:2013-05-20 09:51:54
【问题描述】:
我做了一个简单的页面,当会话到期时移动到另一个页面。我已将时间设置为 50 秒,之后它会移动到一个页面但不幸的是它没有移动,我无助地知道哪里出了问题。如果您能解决我的问题,我将不胜感激
function x(){
var timeOut =<%=session.getAttribute("login")%>;
var checkTimeout;
checkTimeOut = function(){
if(timeOut==null || timeOut==""){
window.location.replace("failedSession.jsp");
//document.getElementById("b").innerHTML="session timed out";
// redirect to timeout page
}else{
window.setTimeout(checkTimeOut, 1000); // check once per second
}}
checkTimeOut(); // this is where you insert checkTimeOut function so that when you call x(), this will execute in the end.
}
【问题讨论】:
-
如果您在这行 JavaScript 的末尾添加一个分号以便与其他代码匹配,您会发现您的代码更易于阅读: var timeOut = ;