Possible Duplicate:
setTimeout Internet Explorer
Am I missing something here or is there a problem in Internet Explorer when passing function parameters to a setTimeout
calling the same function?
This will run forever in Internet Explorer:
function myFunction(myParam, tries){
if (typeof tries == "undefined"){
tries = 0;
}
tries++;
if (tries < 2){
setTimeout(myFunction, 50, myParam, tries);
}
}
myFunction("something");
Is there a way to work around that problem?
The explanation and solution are in the MDN :
http://fiddle.jshell.net/rH3gx/1/
http://fiddle.jshell.net/rH3gx/2/
You need to wrap the function in a function which requires no arguments: