function sleep(ms){
var time = new Date();
time.setTime(time.getTime() + ms);
while(new Date().getTime() < time.getTime());
}
window.onload = function(){
sleep(5000);
alert('5秒钟,想我没~~~');
}
function sleep(ms){
var time = new Date();
time.setTime(time.getTime() + ms);
while(new Date().getTime() < time.getTime());
}
window.onload = function(){
sleep(5000);
alert('5秒钟,想我没~~~');
}
本文标题:不使用setTimeout的延迟执行
本文链接:https://www.haomeiwen.com/subject/dmtfnqtx.html
网友评论