函数节流,待解决。

function throttle(method,delay,duration){
            var timer=null, begin=new Date();
            return function(){
                var context=this, args=arguments, current=new Date();;
                clearTimeout(timer);
                if(current-begin>=duration){
                     method.apply(context,args);
                     begin=current;
                }else{
                    timer=setTimeout(function(){
                        method.apply(context,args);
                    },delay);
                }
            }
}

window.onresize=throttle(resizehandler,100,200);
 n=0;
        function resizehandler(){
            console.log(new Date().getTime());
            console.log(++n);
        }
原文地址:https://www.cnblogs.com/zhangzs000/p/6226223.html