JavaScript Wheel Event - 使用JavaScript处理浏览器的鼠标滑轮事件

魏书
2023-12-01

参考网址:点击打开链接


注册检测事件:

{

            if (isIE) {
            //alert(document.attachEvent);
            document.attachEvent('onmousewheel', stopFunc); //IE < 9
                //document.addEventListener('wheel', stopFunc, false); //IE >=9  
            } else {
                window.addEventListener('wheel', stopFunc, false);  //Firefox version 
                window.addEventListener('mousewheel',stopFunc, false); //safria chrome
            }

}

删除检测事件:

{

      if (isIE) {
            document.detachEvent('onmousewheel', stopFunc);
        }
        window.removeEventListener('wheel', stopFunc, false);  //Firefox 
        window.removeEventListener('mousewheel', stopFunc, false); //safria chrome

}


 1.IE7-IE10上测试可用;

 2.safria 5-safria 6上测试可用;

 3.Firefox  V21上测试可用;

 4.Chrome Version 26.0.1410.43上测试可用;




 类似资料: