homepage Welcome to WebmasterWorld Guest from 54.226.0.225
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
Forum Library, Charter, Moderators: phranque

Website Technology Issues Forum

    
Need Java script delay code
How to add timer to any script...
BrettLaCroix




msg:666869
 8:18 pm on Jan 13, 2001 (gmt 0)

Is there a one line command that says "pause for this amount of time" in Javascript?

As you can tell, I know very little.

I did find some timers, but they were complete routines... and when I tried to "plug them in" into some existing scripts I have... I seem to have problems with subroutines inside of subroutines... or one function inside of another.

So... I am looking for a one line command that says "delay this many seconds before going to the next command."

Thanks,

Brett

 

tedster




msg:666870
 8:54 pm on Jan 13, 2001 (gmt 0)

You probably can use setTimeout(code,delay) [developer.irt.org]

However, this doesn't work exactly the way you described -- that is, it doesn't simply pause for a set period while going through a series of JavaScript commands.

Rather, whatever the "code" string is -- usually the name of a function defined earlier in the code -- JavaScript will delay the execution of that code for the amount of time specified by "delay" (in milliseconds).

Nevertheless, other commands that follow the setTimeout() line will continue to execute, so the effect is not the same as "don't do anything for xxx milliseconds".

BrettLaCroix




msg:666871
 9:06 pm on Jan 13, 2001 (gmt 0)

I am finding out that there is no pause or sleep command in javascript.

I was hoping there was a way to:

execute statement1
count to 10000 (i.e. 10 seconds)
execute statement2

-Brett

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved