[Greasemonkey] setTimeout() problems

Jeremy Dunck jdunck at gmail.com
Wed May 24 11:31:01 EDT 2006


On 5/24/06, Premshree Pillai <premshree.pillai at gmail.com> wrote:
> On 5/24/06, Jonathan Buchanan <jonathan.buchanan at gmail.com> wrote:
>    var arr = new Array("foo", "bar", "baz");
>    for (var i=0; i<arr.length; i++) {
>       window.setTimeout(
>          function(arg) { return function() { alert(arg); }; }(arr[i]),
>          1000
>       );
>    }

Using GM 0.6.4 and FF 1.5.0.3, this does 3 alerts in series (foo, bar,
baz) for me.

Did I misunderstand the expected behavior?   Is this exact code not
working for you, or was this intended as a simplified example?


More information about the Greasemonkey mailing list