setTimeout Internet Explorer [英] setTimeout Internet Explorer

查看:156
本文介绍了setTimeout Internet Explorer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MSIE中有以下javascript:

I have the following javascript in MSIE:

setTimeout(myFunction, 1000, param );

这似乎适用于除Internet Explorer之外的所有浏览器。 param只是没有转发到该函数。看看调试器,它是未定义的。

this seems to work in all browsers except internet explorer. the param just doesnt get forwarded to the function. looking at the debugger, it is undefined.

推荐答案

param 在互联网上explorer指定 myFunction 中的代码是JScript,JavaScript还是VBscript 另请参阅: MSDN 。它的行为与其他浏览器不同。

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.

以下方法有效:

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

前一行并不完全模仿 setTimeout 在Firefox等。要传递一个变量,不受以后更新到 param 变量的影响,请使用:

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);

这篇关于setTimeout Internet Explorer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆