/    Sign up×
Community /Pin to ProfileBookmark

Timer management between 2 frames

Hi,
I’m currently trying to manage a session timeout with a 2 frames window.
In both frames I have forms, and my goal is to clear the timer and set it again every time any button on any of both frames is clicked.

Basically, how I handle this right now is:

In the parent’s frame:

[code]
<head>
<script language=”Javascript”>
var timer;
</script>
</head>
[/code]

in the frames’ forms:

[code]
<form name=”myform” action=”myaction” method=”POST” onSubmit=”return resetTimer();”>
[/code]

the resetTimer function:

[code]
function resetTimer()
{
var timerval;
parent.timer=clearTimeout(parent.timer);
timerval = GetCookie(“timer”) * 1000;
parent.timer=setTimeout(‘logout();’,timerval);
}
[/code]

Now I would expect that this would affect the same timer from both frames, but it seems to consider two seperate timers from both frames. So if I set my timer for 1 minute and that I click on a button on frame1 then wait 30 seconds, click on a button on frame2, I’ll have a timeout after 30 more seconds (the 30 remaining seconds of the timer set by frame1) and it goes the same way around too…

Anyone has a clue what I may have done wrong?

thanks in advance

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@jojolepaboauthorMar 17.2004 — Ok I had my answered yesterday evening on another forum, guess I can share my bit of experience:

my main mistake was to call the setTimer and clearTimer at frame level... solution was simply to put

<i>
</i>[b]top.[/b]setTimeout(top.timer);
top.timer=[b]top.[/b]setTimeout("logout();", &lt;timeout delay&gt; );


instead of

<i>
</i>setTimeout(top.timer);
top.timer=setTimeout("logout();", &lt;timeout delay&gt; );


also making sure the logout() function is implemented in the top...
×

Success!

Help @jojolepabo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...