使用setTimeout()进行javascript超时/睡眠 [英] javascript timeout/sleep using setTimeout()
本文介绍了使用setTimeout()进行javascript超时/睡眠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置2秒钟的超时时间来等待页面控件被填充?我想使用javascript我尝试了以下操作,但无济于事:
How can I set a 2 second timeout to wait for page controls to be populated? I want to use javascript I have tried the following but to no avail:
setTimeout(function(){},2000);
setTimeout(2000);
任何人都可以提供指针吗?
Anyone able to provide a pointer?
推荐答案
setTimeout(function(){
//put your code in here to be delayed by 2 seconds
},2000);
要延迟的代码需要放在setTimeout函数中.
The code you want to delay needs to sit inside the setTimeout function.
这篇关于使用setTimeout()进行javascript超时/睡眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文