滚动(卷动)事宜:滚轮、拖拽滚动条、键盘方向键

<script type=&#34;text/javascript">//滚轮事宜:滚轮//卷动事宜:滚轮、拖拽滚动条、键盘↕键//IE和Chromegunlun.onmousewheel = function(){this.innerHTML += "IE和Chrome<br/>";}//Firefoxgunlun.addEventListener("DOMMouseScroll", function(){this.innerHTML += "Firefox<br/>";})</script>

判断滚轮方向

<script type="text/javascript">//滚轮事宜:滚轮//卷动事宜:滚轮、拖拽滚动条、键盘↕键//IE和Chromegunlun.onmousewheel = function(e){var ev = e || window.event;console.log(ev.wheelDelta);//判断滚轮方向的//上120//下-120this.innerHTML += "IE和Chrome<br/>";}//Firefoxgunlun.addEventListener("DOMMouseScroll",function(e){var ev = e || window.event;console.log(ev.detail);//滚轮方向//上-3//下3this.innerHTML += "Firefox<br/>";})</script>

兼容性封装

html滚轮切换图片JavaScript 滚轮卷动事宜 jQuery
(图片来自网络侵删)

<script type="text/javascript">//滚轮事宜:滚轮//卷动事宜:滚轮、拖拽滚动条、键盘↕键//IE和Chromegunlun.onmousewheel = gl;//Firefoxgunlun.addEventListener("DOMMouseScroll",gl)function gl(e){var dir;//事宜工具的兼容var ev = e || window.event;if(ev.wheelDelta){//IE和Chromedir = ev.wheelDelta>0?"上":"下";}else if(ev.detail){//FireFoxdir = ev.detail>0?"下":"上";}console.log(dir)}</script>