IE and setTimeout...
-
setTimeout works great in Firefox, but I can't get IE to pass more than one argument. Does anyone know a trick?
-
setTimeout works great in Firefox, but I can't get IE to pass more than one argument. Does anyone know a trick?
-
setTimeout works great in Firefox, but I can't get IE to pass more than one argument. Does anyone know a trick?
setTimeout(function() { myfunc(param1, param2, param3); }, 300);
...should work in most browsers, and will call
myfunc
passing whatever you give it (in this case,param1
,param2
,param3
); You could also write a helper function to make this a bit cleaner:function setTimeoutParam(ms, func)
{
var args = Array.prototype.slice.call(arguments, 2);
setTimeout(function() { func.apply(this, args); }, ms);
}...which you can then call with the timeout value, function, and any number of desired parameters to that function, for example:
setTimeoutParam(1000, alert, "called after 1 second");
Citizen 20.1.01
'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'