setTimeout Internet Explorer

param in Internet explorer specifies whether the code in myFunction is JScript, JavaScript or VBscript See also: MSDN. It does not behave like other browsers.

The following will work:

setTimeout(function() {
    myFunction(param);
}, 1000);

The previous line does not exactly mimic setTimeout in Firefox etc. To pass a variable, unaffected by a later update to the param variable, use:

setTimeout( (function(param) {
    return function() {
        myFunction(param);
    };
})(param) , 1000);

Leave a Comment