禁用滚轮 开启滚轮
2018-03-07 本文已影响0人
web佳
function disabledMouseWheel() {
if (document.addEventListener) {
document.addEventListener('DOMMouseScroll',scrollFunc,false);
}//W3C
window.onmousewheel =document.onmousewheel =scrollFunc;//IE/Opera/Chrome
console.log(12345)
}
function scrollFunc(evt) {
evt = evt ||window.event;
if(evt.preventDefault) {
// Firefox
console.log(12)
evt.preventDefault();
evt.stopPropagation();
}else {
// IE
evt.cancelBubble=true;
evt.returnValue =false;
}
console.log(121312)
return false;
}
//禁用滚轮
disabledMouseWheel()
//开启滚轮
window.onmousewheel =document.onmousewheel =true;