阻止网页内部滚动条mousewheel事件冒泡

利用鼠标滚轮在网页内部滚动时触发滚动事件,当滚轮到达元素顶部或底部时不触发浏览器窗口的滚动事件

function preventScroll(id){
        var _this = document.getElementById(id);
        if(navigator.userAgent.indexOf("Firefox")>0){
            _this.addEventListener('DOMMouseScroll',function(e){
                _this.scrollTop += e.detail > 0 ? 60 : -60;   
                e.preventDefault();
            },false); 
        }else{
            _this.onmousewheel = function(e){   
                e = e || window.event;   
                _this.scrollTop += e.wheelDelta > 0 ? -60 : 60;   
                return false;
            };
        }
        return this;
}
原文地址:https://www.cnblogs.com/hmycheryl/p/9430418.html