function sleep(sleepTime) {
for(var start = new Date; new Date - start <= sleepTime;) {}
}
function main(){
alert("关注公众号【小知识酷】,搜索“WPS JS”获取更多相关教程")
sleep(3000)
alert("已经给你3秒钟了,相信你已经关注了,爱你~")
alert("再给你5秒钟时间,你可以看看其他的内容");
sleep(5000);
alert("酷酷提醒你代码即将结束");
}
code description
- We customize a
sleep
functionstart
for the initial time new Date
is the latest time -start
= the time that has elapsed- When we want to use it, just use
sleep()
it directly