IE8中的settimeout问题 [英] settimeout issue in IE8

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

问题描述

我在IE8中使用javascript setTimeout函数时遇到了一个奇怪的问题。
我想像这样使用'setTimeout'函数 -

I am facing a strange issue while using javascript setTimeout function in IE8. I want to use the 'setTimeout' function like this -

setTimeout(timeout,2000, {name:'saarthak'});

    function timeout(opts)
    {       
        alert('hello ' + opts.name);
    }

setTimeout的第三个参数是我要传递给的参数调用功能。这在FF,Chrome中运行得很好,但在IE8中却没有。

the third parameter of the setTimeout is the argument that I want to pass to the calling function. This is working perfect fine in FF, Chrome but not in IE8.

有没有人知道可以做些什么?或实现这一目标的任何工作?

Does anybody have any clue what could be done? Or any work around of achieving this?

谢谢

推荐答案

可能不支持那里,所以请改为:

Probably not supported there, so have this instead:

window.setTimeout(function() {
    timeout({name:'saarthak'});
},2000);

含义从匿名函数中调用函数。

Meaning call your function from within anonymous function.

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

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