我想使用 window.setTimeout 每 0.1 秒在 TruClient (Firefox) 中运行一个函数:
function foobar(delay_accumulator){
if(delay_accumulator >= 100)//10 seconds
return;
//do something
window.setTimeout(function() { foobar(delay_accumulator+1); }, 100);
}
foobar(0);
但是,该步骤失败,给出以下错误:
** 2: 评估 JavaScript 代码函数 foobar(delay_accumula...奥巴尔");福巴(0);** 失败 - 发生异常: NS_ERROR_NOT_AVAILABLE: 组件返回的失败代码: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMJSWindow.setTimeout]
为什么设置超时不可用?我可以使用其他解决方案吗?
编辑:Truclient在工具箱中有一个"等待"函数,但它的最小粒度为1秒,而不是setTimeout的毫秒。
试试 nsiTimer: https://developer.mozilla.org/en/nsITimer