setTimeout 的最小毫秒值是多少? [英] What is minimum millisecond value of setTimeout?

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

问题描述

我想放

var minValue = 0;
if ( typeof callback == 'function' ) {
    setTimeout( callback, minValue );
}

当我用 JavaScript 实现回调函数时的这段代码.

this code when I implement callback function with JavaScript.

但我发现现代浏览器和一些旧浏览器

But I've found that modern browsers and some old browsers

有不同的最小超时值.

我知道零不可能是最小值.

I know that Zero cannot be minimum value.

setTimeout 的最小值是什么

现代浏览器和一些旧浏览器是否存在兼容性问题?

推荐答案

我认为 10 将是所有浏览器中最可靠的最小值,因为我已经看到很多代码使用它.

I think that 10 will be the most reliable minimum in all browser, since I've seen a lot of codes using it.

但是,4 毫秒是 HTML5 的最小值

事实上,4ms 是由 HTML5 规范指定的,并且在 2010 年及以后发布的浏览器中是一致的.在 (Firefox 5.0/Thunderbird 5.0/SeaMonkey 2.2) 之前,嵌套超时的最小超时值为 10 毫秒.

In fact, 4ms is specified by the HTML5 spec and is consistent across browsers released in 2010 and onward. Prior to (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2) , the minimum timeout value for nested timeouts was 10 ms.

这篇关于setTimeout 的最小毫秒值是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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