我使用了这段代码(后跟一个填充"tcap"textarea的xmlhttprequest):
st=setTimeout(checkme(),4000)
Run Code Online (Sandbox Code Playgroud)
在哪里checkme():
function checkme() {
if (typeof (st) != 'undefined') clearTimeout(st)
if (document.getElementById("tcap").innerHTML.length > 0) {
document.getElementById('waitmsg').style.display = 'none'
} else {
st = setTimeout(checkme(), 1000)
}
}
Run Code Online (Sandbox Code Playgroud)
如果我运行它,它冻结Firefox 19没有错误消息.但是如果我用第一个参数替换(在代码和checkme()函数中):
st=setTimeout(function(){checkme()},4000)
Run Code Online (Sandbox Code Playgroud)
它工作正常.所以我的问题是:checkme()使用或不使用anon函数调用函数有什么区别?为什么在第一种情况下会冻结Firefox?
谢谢