08-03-2009, 05:12 PM
| THREAD STARTER
#1 (permalink)
|
| NamePros Member Join Date: Apr 2005 Location: N.C.
Posts: 186
| Help! setTimeout not working with random number Hello, ????: NamePros.com http://www.namepros.com/programming/600886-help-settimeout-not-working-random-number.html
I can not seem to get this to work. It is a recursive function that calls itself. It is supposed to delay 10 seconds plus a random amount. The problem I'm having is that it repeatedly calls itself every 10 seconds (exactly) without adding a random number of seconds. Code: var i=0;
function load(){
.....
i++;
if (i<=someArray.length){
timer=setTimeout("load()", (10000 + Math.floor(Math.random()*10*1000)));
}
} |
| |