Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect on timeout

Status
Not open for further replies.

AnthonyJ20

Programmer
Aug 24, 2005
32
US
I'm using the script below that's been working pretty well. It notifies a user that their session is about to timeout about 5 minutes before it does. It they want to continue they click Okay and the page is refreshed. If they click cancel the session will continue to time out. What I want to do is have it so that if they click cancel they will be redirected to whatever page I choose. How would I do this?


<SCRIPT language="javascript">
function WarnUserTimeout()
{
if (window.confirm('Your session will expire in 5 minutes. Do you want To continue working?'))
{
window.history.go(0)
}
}
</SCRIPT>
</HEAD>
<BODY OnLoad="window.setTimeout('WarnUserTimeout()',(<%=session.timeout%>-5)*60*1000)">
 
can u use an else part where u say ...
else {
window.location=url;
}

regards,
Brian
 
Thanks for the response brianpercival. I'm still trying to get the hang of Java. How would I include the else statement you mentioned?
 
function WarnUserTimeout()
{
if (window.confirm('Your session will expire in 5 minutes. Do you want To continue working?'))
{
window.history.go(0)
}
else {
window.location='YOURURL'
}

}

hope this is what you wanted. BTW, just to let you know that this is not java, this is javascript, totally different from java thought they kind of look alike sometimes.

regards,
Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top