[thelist] Javascript setTimeout losing object properties

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Sat Jun 25 14:27:13 CDT 2005


> You're passing obj to fadIn() and fadeOut() as a string in your
> setTimeout().  Remove the extra single-quotes and your probably should be
> solved:
> 
> setTimeout("fadeIn(" + obj + ")", 100);
> 

it won't be solved.

fadeIn function expects an object reference.
(
function fadeIn(obj)...
)

setTimeout("fadeIn(" + obj + ")", 100); 

will be resolved to setTimeout("fadeIn([object])", 100)  since no
toString() method is defined for the object.

and 

fadeIn([object]) 

is a syntax error and will generate a runtime error when the timer
thread executes the code after 100 milli-seconds.

Correct me, if I am not seeing something very apparent.

Cheers,
Volkan.


More information about the thelist mailing list