Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

Need Java script delay code

How to add timer to any script...



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

Inactive Member
Account Expired


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."



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

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
votes: 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".


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

Inactive Member
Account Expired


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



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members