[thelist] Global vs. Local Variable Oddity

Lee Kowalkowski lee.kowalkowski at lycos.com
Fri Feb 17 15:42:24 CST 2006


> From: "Rob Smith" <rob.smith at lexjet.com>
>
> I grovel at your feet and ask yee kindly to look at:
> http://www.lexjet.com/lexjettest/ . Click a bunch of links (the five
> gray on the right side). Wait for about 6 seconds and watch the slides
> flutter before your very eyes.
> 
> I'm guessing it has something to do with local vs. global variables of
> "slidespeed". If you can figure this out, I'd be very thankful.

Rob,

Clicking on a link invokes "activateslide".  The last line of this function makes a delayed call to "slideit", but so does "slideit".  I.e. slideit is calling itself.

Repeatedly invoking "activateslide" generates more timeouts which will all lead to more and more frequent executions of "slideit".

I'm not 100% sure what your desired behaviour is, but suspect you may want to either:
a/ Store the integer returned from setTimeout() so you can pass it to clearTimeout() whenever the user invokes "activateslide".
b/ Use a simplified design based on setInterval() and clearInterval().

- LK


-- 
_______________________________________________

Search for businesses by name, location, or phone number.  -Lycos Yellow Pages

http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10




More information about the thelist mailing list