내 응용 프로그램의 자동 로그 아웃 페이지를 만들려고합니다. 나는 고전 asp와 타이머를 처리하는 자바 스크립트를 사용하고 있습니다. 3 페이지 js 스크립트 페이지, js 파일을 호출하고 OnLoad()를 사용하여 타이머를 시작하는 홈 페이지가 있습니다. 4 초 후 사용자가 세션을 계속할 것인지 묻는 창이 나타납니다. 그러나 창이 뜨면 logout_alert.asp 페이지에서 yes를 클릭하면 홈 페이지의 타이머가 업데이트되지 않습니다. 타이머를 업데이트하는 팝업 창은 어떻게 만듭니 까? 다음은 스크립트입니다. 사전에 도움,다른 페이지에서 Javascript 타이머 제어?
프랭크 G.
에 대한
덕분에 나는 세 페이지가 있습니다. 이 예 페이지 1, 페이지 2 및 페이지 3
PAGE 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 -->
PAGE 2 = homepage.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()" />
PAGE 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>
안녕하세요 도움을 주셔서 감사합니다. 타이머가있는 창은 프레임 안에 있습니다. 이 프레임에 대한 코드는 다음과 같습니다. 프레임은 "autologout" 스크립트 자체는 js 파일 안에 있습니다. 나는 두 개의 창 사이에 js 파일을 공유하지만 삽입하고 있습니다. 하지만 그 페이지 자체에 버튼이있는 경우에만 타이머를 재설정 할 수 있습니다. 예를 들어 타이머 페이지에 버튼을 놓으면 작동하는 시간을 멈추지 만 타이머에 멈추라 고 말하면 팝업이 표시됩니다. 어떠한 제안? 고마워! –
window.opener, window.opener.frames [], top.opener.myFrameName.window.myFunction() ...을 사용하여 부모 창 (또는 프레임)에서 함수를 호출 할 수 있습니다. 'stopRemoteTimer (top.opener.myFrameName);'와 같은 오프너에 대한 참조를 전달할 때이를 수행하는 자식 윈도우의 JavaScript입니다. 부모 창에서 실제 함수를 그런 식으로 처리 할 것입니다. JS가 자체 샌드 박스에서 실행될 때 하나의 윈도우 또는 다른 컨텍스트에서 모든 계산 및 연산을 수행해야합니다. – ingyhere