Solved

A client side javascript that redirects to Logout.aspx

Posted on 2004-05-01
4
470 Views
Last Modified: 2008-02-26
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!
0
Comment
Question by:Cali_Salas
  • 3
4 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 50 total points
ID: 10968641
<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
 

Author Comment

by:Cali_Salas
ID: 10968776
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
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 50 total points
ID: 10968818
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10971636
Glad I could help.  Thanks for the A. :^)

Cd&
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JS Plugin Chaining 2 32
Tableau and Javascript: How to export an array to excel with formatting 11 59
alert before form submission 6 30
Capture logon name 13 31
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now