[Javascript] setTimeout madness

Christopher Basken chriz at basken.com
Thu May 16 11:12:22 CDT 2002


I should be able to get this, but for some reason it's not working.  All I 
want to do is call a function after 3 seconds.  I'm doing it like this:

var timeID = setTimeout("miniHide()",3000,navDivID);

If I test for the validity of navDivID just before the setTimeout call 
(with an alert()) it comes up fine (it's just a string).  But miniHide 
can't seem to understand it.  Right now, miniHide() is just an echo function:

function miniHide(navDivID) {
   alert(navDivID);
}

But when I run this, I get "undefined".  navDivID is not a global value.

I've tried a number of permutations on this, like passing navDivID inside 
the parens in the setTimeout call (setTimeout("miniHide(navDivID)",3000);) 
and actually cycling through the arguments array in miniHide(), neither 
with any success.  If I pass the actual string in as an argument, it works.

What's the deal with setTimout() and arguments?




More information about the Javascript mailing list