Monday, March 30, 2009

Passing Variable To SetInterval

Today, I need to rotate the background image using javascript. I use the function setInterval to acheive this. However, I can't pass variable to setInterval as several errors occur.

Here is some websites that talking about this problem:
http://www.bigresource.com/JAVASCRIPTS-Passing-variable-to-setInterval-E2H3OB74.html#Gf8cAgFL

http://alexle.net/archives/169

PS: better use anonymous function to deal with it
For example,
setInterval(function(){alert(variable_a);}, 500);

No comments: