bug_x

导航

 
1 function sleep(milliseconds) {
2   var start = new Date().getTime();
3   for (var i = 0; i < 1e7; i++) {
4     if ((new Date().getTime() - start) > milliseconds){
5       break;
6     }
7   }
8 }

 



other version to see https://stackoverflow.com/questions/6484321/sleep-in-javascript-no-settimeout?noredirect=1&lq=1

posted on 2018-02-11 11:51  bug_x  阅读(170)  评论(0编辑  收藏  举报