[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setTimeout() bug



>loopID = setTimeout(loopBackground(),1000)

here's the problem, your line should read

loopID = setTimeout("loopBackground()", 1000)

the first argument should be a string indicating the function to be
executed, rather than a nested function call.  the reason it says undefined
is because the return value of loopBackground is interpreted as the function
you want to be executed at time out.

the whole function should be changed to:

>function loopBackground() {
>  if (COLOR > 0) {
>   document.bgColor = '#' + COLOR
>   alert(COLOR)
>   COLOR -= 111111
>   loopID = setTimeout("loopBackground()",1000)
>  } else {
>    document.bgColor = '#000000'
>    // clearTimeout(loopID)
>  }
>}


--------------------------------------------------------------------
This message came from the mailing list javascript. For help using the
mailing list software, please send a message to 'majordomo@obscure.org'
with the message body 'help'. To unsubscribe, send a message to
'majordomo@obscure.org' with the message body 'unsubscribe javascript'.