Friday, February 28, 2014

setTimeout usage in javascript

Generally window.setTimeout or setTimeout is similar function. They perform call to a custom defined javascript function after specific amount of time.

There are browsers which makes the below line valid

setTimeout(callingAFunction(),400);

Which calls a function called "callingAFunction" after 400 milliseconds. But this function creates a problem in IE8 which gives a script error. Instead use like this,

setTimeout(callingAFunction,400);

No comments:

Post a Comment