Skip to content

js中mousewheel和DomMouseScroll事件的区分

网上资料非常多,很多都过时了(包括以下代码,有天也会过时哦)。 代码如下:

if(window.addEventListener){
    var type = (document.getBoxObjectFor)?'DOMMouseScroll':'mousewheel';
    window.addEventListener(type, _onMousewheel, false);
}else{
    document.onmousewheel = _onMousewheel;
}

测试了以下浏览器:

  • IE(包含以IE为内核的浏览器:Maxthon,sogo)
  • Firefox
  • Chrome
  • Opera

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*