js 文档加载完成之后执行 备用

 1 //文档加载完成之后执行
 2 (function(){
 3         var _globeCallback;
 4         window.$$ = function(callback){
 5             _globeCallback = callback;
 6         };
 7         function documentReady(){
 8             _globeCallback();
 9         }
10     //document ready --mobile -webkit
11     var listenerDocumentReady = function(){
12         console.log(document.readyState);
13         if(document.readyState=='complete'){
14              documentReady();
15              clearInterval(_readyInterval);
16          }
17     }
18     var _readyInterval = setInterval(listenerDocumentReady,10);
19 })();

 

posted @ 2015-04-28 19:01  淡然_  阅读(487)  评论(0编辑  收藏  举报