A client side javascript that redirects to Logout.aspx

Hi,
Could anyone help me with some piece of javascript code? I need to create a client side javascript that will redirect to Logout.aspx  20 minutes after the current page was rendered.
And where do I have to call that javascript? On <body load=> ?
Thanks!
Cali_SalasAsked:
Who is Participating?
 
COBOLdinosaurConnect With a Mentor Commented:
<body onload="setTimeout('yourfunction()',20000)">

And your function would go in the head like this:

<script type="text/javascript">
function yourfunction()
{
// any code you want to execute before logging them off
location.href='Logout.aspx';
}
</script>

Cd&
0
 
Cali_SalasAuthor Commented:
Thanks, but what about if there's a previous javascript function onload ? In my case, I already call another javascript function:

<SCRIPT language="javascript">
function SaveScroll()
{
    document.all.item('txtScroll').value = theBody.scrollTop
}
function SetScroll()
{
    theBody.scrollTop = document.all.item('txtScroll').value
}

</SCRIPT>
<body id="theBody" onscroll="Javascript:SaveScroll()" onload="Javascript:SetScroll()">

Is there any other place where I could put "setTimeout('LogoutFunction()',20000)" ?
0
 
COBOLdinosaurConnect With a Mentor Commented:
You can put any legal sequence of javascript instruction in the event invocation.  I removed the javascript: as it is unnecessary for events becaue they us assume javascript already:

<body id="theBody" onscroll="SaveScroll()"
onload="SetScroll();setTimeout('LogoutFunction()',20000);">

Cd&
0
 
COBOLdinosaurCommented:
Glad I could help.  Thanks for the A. :^)

Cd&
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.