CancelImage Upload

How to take a timeout and delay a function in JavaScript

Thanks to JavaScript's timeout function various fade in, and other effects can be created, that look similar to those found within Flash Programs. Here then is how the JavaScript function setInterval() can be set:

setInterval("yourFunction()", 500);

The first item inside the code example above is obviously the function that you want to call upon. The second is the time delay in micros seconds. One second is equal to 1000 microseconds. Which is some useful information if you wanted to create a clock or a countdown function.

By all means you can create a loop with set interval by defining the function within itself. So if you hade a function named yourFunction(), and you wanted to enter it again under certain circumstances, your code would look something along these lines.

functino yourFunction()
{

        ...

        if(conditions == true)

        setInterval("yourFunction()", 500);

}


Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com