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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onload timer

Status
Not open for further replies.

kettch

Programmer
Mar 5, 2001
110
US
Can someone help me with a time delayed onLoad? I need to be able to call a function in the onLoad, but only after a few seconds have elapsed to allow time for something else on the page to happen.
 
Hello kettch,

Try the setTimeout() method like this.
Code:
<html>
<head>
	<title>Load and Wait</title>
</head>

<body onLoad=&quot;waitSixSeconds()&quot;>

<script language=&quot;JavaScript1.2&quot;>
   function waitSixSeconds(){
      window.setTimeout(&quot;bareTeeth()&quot;, 6000);
   }
</script>


	
<script language=&quot;JavaScript1.2&quot;>
   function bareTeeth(){
      document.write(&quot;<h1>Growl</h1>&quot;);
   }
</script>


</body>
</html>

 
Thanks, I'll remember that, but i found out what i really needed was different that what i thought i needed. I ended up doing this:
Code:
<META HTTP-EQUIV=&quot;refresh&quot; content=&quot;10; url=&quot;someplace&quot;>

it pauses for 10 seconds and then redirects. I just wasn't very good at figuring out exactly what i needed and how to explain it. But thanks anyway! :)
 
I think I might be able to do something similar in my application. I have a data entry form that checks to see if a user has logged on. If they walk away from their browser for say an hour, I want the page to reload itself so they will be forced to go back to a logon page. I already have the code at the beginning of the page to redirect if their session has expired. Is this a good thing to do? Does anybody see any problems with this, besides the user losing the data that they had not saved when they walked away from their browser.

Thanks
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top