1 回答
TA贡献1821条经验 获得超6个赞
window.onload=function()
{
var oBox=document.getElementById('box');
wheel(oBox,function(down){
alert(down);
});
}
function wheel(obj,wheelFn)
{
window.navigator.userAgent.indexOf('Firefox')!=-1 ? obj.addEventListener('DOMMouseScroll',fn,false) : addEvent(obj,'mousewheel',fn);
function fn(ev)
{
var oEvent=ev||event;
var down=oEvent.wheelDelta ? down=oEvent.wheelDelta<0 : down=oEvent.detail>0;
ev.preventDefault&&ev.preventDefault();
wheelFn&&wheelFn(down);
return false;
}
}
function addEvent(obj,sEv,fn)
{
obj.addEventListener ? obj.addEventListener(sEv,fn,false) : obj.attachEvent('on'+sEv,fn);
}
添加回答
举报