
火狐下禁止鼠标滑轮事件bug
火狐是不支持 onmousewheel 事件的,但是他支持 DOMMouseScroll
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
function disabledMouseWheel() { if (document.addEventListener) { document.addEventListener('DOMMouseScroll', scrollFunc, false); }//W3C window.onmousewheel = document.onmousewheel = scrollFunc;//IE/Opera/Chrome } function scrollFunc(evt) { evt = evt || window.event; if(evt.preventDefault) { // Firefox evt.preventDefault(); evt.stopPropagation(); } else { // IE evt.cancelBubble=true; evt.returnValue = false; } return false; } window.onload=disabledMouseWheel; function resize1(){ if (document.addEventListener) { document.addEventListener('DOMMouseScroll', scrollFunc1, false); }//W3C window.onmousewheel = document.onmousewheel = scrollFunc1;//IE/Opera/Chrome } function scrollFunc1(){ //重置滚动事件 }
|
禁止掉之后,可以用resize时间恢复滑轮滚动事件
近期评论