js实现 页面加载 完成 后顺序 执行

 function addLoadEvent(func){
            var oldonLoad = window.onload;
            if(typeof window.onload != 'function'){
                window.onload = func;
            }else{
                window.onload = function(){
                    oldonLoad();
                    func();
                }
            }
        }
        function c1(){
            console.log(1)
        }
        function c2(){
            console.log(2)
        }
        function c3(){
            console.log(3)
        }
        addLoadEvent(c3)
        addLoadEvent(c1)
        addLoadEvent(c2)

 

 

posted @ 2019-04-10 11:09  奔跑的太阳花  阅读(727)  评论(0编辑  收藏  举报