如何使用setTimeout()调用jQuery(document).ready之外的函数?

Bra*_*ayn 1 javascript jquery settimeout

我的代码看起来像:

$(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
    }
    }
});
Run Code Online (Sandbox Code Playgroud)

所以我想做的是延迟执行func1(续); 在searchComplete()函数内部.这样做的原因是所有代码都是使用Google搜索API和PageRank检查,我需要放慢脚本速度,这样我才不会被禁止.(特别是关于公关检查的要求).如果我只是在func1(cont)上使用setTimeout(); 它说没有定义func1(),如果我试图在$(document).ready()之外获取该函数,它会看到该函数,但Google代码不会因为它需要完全加载的页面.

如何修复setTimeout或如何暂停脚本几秒钟?

谢谢!

str*_*ger 5

func1(cont);
Run Code Online (Sandbox Code Playgroud)

window.setTimeout(function() {
    func1(cont);
}, 1000);
Run Code Online (Sandbox Code Playgroud)