【发布时间】:2012-03-13 12:18:07
【问题描述】:
我正在尝试为我的应用程序创建一个自动注销页面。我正在使用 Javascript 来处理带有经典 asp 的计时器。我有三个页面是 js 脚本页面,我调用 js 文件并使用 OnLoad() 启动计时器的主页。 4 秒后会弹出一个窗口,要求用户继续该会话。但是当窗口弹出并且我在 logout_alert.asp 页面上单击“是”时,它不会更新主页上的计时器。如何让弹出窗口更新计时器?以下是脚本。
提前感谢您的帮助,
弗兰克 G.
我有三页。对于此示例,第 1 页、第 2 页和第 3 页。
第 1 页 = logout_timeout.js
这是该页面的脚本。
<!-- Begin
var c=0;
var t;
function ClockCount(){
c=c+1;
//Show the clock value on the home page text field.
document.timerform.clock.value = c;
if (c == 7) {
//The user never responded so we will kill the session and log them out.
alert("Your session has timed out you are logged out.");
window.location.href = "logout.asp"
}
else if (c == 4) {
//We will popup a window to let the user know there about to be logged out.
//This will give the user a chance to keep the session alive.
logoutalert = window.open("logout_alert.asp", "logoutalert", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=420,height=145,left = 465,top = 250");
}
//The timer will go round and round while recalling this function.
t = setTimeout("ClockCount()",1000);
}
//Call to start the timer.
function StartClock() {
ClockCount();
}
//Called to stop the timer.
function StopClock() {
c=0 //Clear the timer.
clearTimeout(t); //Stop it.
}
// End -->
第 2 页 = 主页.asp
这个页面我调用 logout_timeout.js 文件。
<script src="logout_timeout.js" type="text/javascript"></script>
<body OnLoad="StartClock()">
This will show our clock while its processing.
<form id="timerform" name="timerform" method="post" action="">
<input type="text" name="clock" id="clock" />
</form>
Used now just for testing!
<input type="submit" name="continue" id="continue" value="START" onClick="StartClock()" />
<input type="submit" name="continue" id="continue" value="STOP" onClick="StopClock()" />
第 3 页 = logout_alert.asp
这个页面会弹出来通知用户他们即将被注销。
<script src="logout_timeout.js" type="text/javascript"></script>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="Thread_Title">SESSION TIMEOUT Alert!</td>
</tr>
<tr>
<td width="85%" class="DataRows">Your session is about to timeout. Would you like to continue using WOTTS?</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><form id="timerform" name="timerform" method="post" action="">
<input type="text" name="clock" id="clock" />
</form></td>
</tr>
<tr>
<td>
<input type="submit" name="continue" id="continue" value="START" onClick="StartClock()" />
<input type="submit" name="continue" id="continue" value="STOP" onClick="StopClock()" /> </td>
</tr>
</table>
【问题讨论】: