dojo
setTimeout(dojo.hitch(this, function(){
this.onClickCount();
}), 3000);
普通應用
在js中,延遲執行函數有兩種,setTimeout和setInterval,用法如下:
function testFunction(){Console.log('hovertree.com');}
setTimeout(testFunction(),6000); //6000毫秒后執行testFunction()函數,只執行一次。
setInterval("testFunction()","6000");//每隔6000毫秒執行一次testFunction()函數,執行無數次。
varinterval = window.setInterval("testFunction()","6000");//
window.clearInterval(interval); //停止執行setInterval循環。
當我們想讓testFunction()函數每隔6000毫秒執行一次,執行10000毫秒后停止執行時,可以用兩者三者結合使用來實現。
varinterval2 = window.setInterval("testFunction2()",6000);
setTimeout(function() {window.clearInterval(interval2);},10000);