[Javascript] setTimeout madness

Peter Brunone peter at brunone.com
Thu May 16 11:24:27 CDT 2002


Christopher,

	I don't think there's a third parameter for setTimeout, and even if there
were, it looks like you want to pass the parameter to miniHide().  Try this
(making sure that navDivID is the correct name of the variable, of course):

setTimeout("miniHide('" + navDivID + "')", 3000);

	See, the first param of setTimeout is a string which evaluates to a
function call, so you have to build the string to include the correct
variable.  If it's not a string but an integer or object reference, then you
can remove the single quotes.

Cheers,

Peter

|-----Original Message-----
|From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]On
|Behalf Of Christopher Basken
|
|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?
|
|_______________________________________________
|Javascript mailing list
|Javascript at LaTech.edu
|https://lists.LaTech.edu/mailman/listinfo/javascript
|




More information about the Javascript mailing list