我的代码看起来像:
$(document).ready(function(){
var cont = 0;
function func1(cont)
{
//Some code here
search.setSearchCompleteCallback(this, searchComplete, null);
//Some other code
}
func1(cont);
function searchComplete()
{
//Some code
cont += 1;
if (cont < length ) {
func1(cont);
} else {
// Other code
}
}
});
所以我想做的是延迟 func1(cont); 的执行。在 searchComplete() 函数内部。这样做的原因是所有代码都是为了与 Google 搜索 API 和 PageRank 检查一起工作,我需要放慢脚本速度,以免被禁止。(特别是对于它提出的关于 PR 检查的请求)。如果我只是在 func1(cont) 上使用 setTimeout(); 它说没有定义 func1(),如果我尝试在 $(document).ready() 之外获取函数,它会看到该函数,但 Google 代码不会因为它需要完全加载页面。
如何修复 setTimeout 或如何将脚本暂停几秒钟?
谢谢!