js 自定义方法 实现停留几秒 sleep

function sleep(numberMillis) { 
    var now = new Date(); 
    var exitTime = now.getTime() + numberMillis; 
    while (true) { 
       now = new Date(); 
       if (now.getTime() > exitTime) 
       return; 
    } 
}

 

posted @ 2015-12-28 20:42  龙昊雪  阅读(1344)  评论(0编辑  收藏  举报