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

WHAT MAY I PUT IN THE CODE TO MAKE A 'DELAY OF TIME'? 1

Status
Not open for further replies.

seba070707

Programmer
Joined
Aug 6, 2001
Messages
13
Location
AR
Hello.

What code is used in Javascript to add a Delay of time?


Is it Delay(n); ?? It didn't work.

Any help would be greatly appreciated. THANKS !!!!
 
I'm not sure what exactly you want.
I think setTimeout function should do.

setTimeout("functionname to be processed after delay of n here", n); //n is an integer. It depends how long you want it to be delayed.

Or, if you want a page to be delayed by certains seconds before it gets display. You can simply use the
<META HTTP-EQUIV=REFRESH CONTENT=5;URL=YourWebPageLocation> //where 5 is 5 seconds.

I hope it helps

Regards
 
if you are looking for an eqivilant to BASIC's wait {n} where n is the number of mseconds to wait, there is no js equivilant. theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
You could put the code you want to be delayed in a different function
(e.g &quot;DelayedFunc()&quot;) and call it from the original function, using
setTimeout(&quot;DelayedFunc()&quot;,500); where &quot;500&quot; is the number of miliseconds delay

Another option is to use something like this:
setInterval(&quot;y()&quot;,100);
function y()
{
window.status=&quot; }

function y() will be called EVERY 100 miliseconds.
(I put this script in the body, not the header part of the page)
 
SetTimeout is the way to go. I usually end up working it into every script I write!

You could also use a for loop... but the time this takes depends on the user's computer. Guess thats why they made SetTimeout! LOL ...Theres a time and a place for everything though. -gerrygerry
geraldschafer@hotmail.com
 
hmm, as I think back now, I remember someone posting some code that does delay the js script for x amount of seconds. of course it was just a looping function that checked the seconds of the computer clock, but that was all that was needed.

I searched the js and html forums with no avail, sorry, I cant find it for ya :-(

theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top