| simple Timeout & clear
|
sssweb

msg:4532622 | 9:09 pm on Jan 2, 2013 (gmt 0) | I'm having trouble with what should be a simple Timeout and clear. Here's my code: function test() { var Timer = setTimeout(function() { alert("hello"); }, 1000); } test(); The code runs in a slideshow, and when the slide transitions out, I clear the timeout using: clearTimeout(Timer); For some reason, the clear causes the slideshow navigation to hang and remain stuck on the current slide. Is there something wrong with my code? Better yet, can I do this w/o coding the Timeout as a function w/in a function? That would likely solve it.
|
sssweb

msg:4532637 | 9:25 pm on Jan 2, 2013 (gmt 0) | I got it. Timer needs to be defined outside the function: var Timer; function test() { Timer = setTimeout(function() { alert("hello"); }, 1000); }
|
|
|