doctype html>html>head>meta charset=utf-8>title>标题title>meta name=keywords content=>meta name=description content=>style> *{margin:0; padding:0; list-style:none;} body{ height: 2000px; } #box{ width: 200px; height: 200px; background: green; }style>head>body>div id=box>div>script> var box=document.getelementbyid('box'); var str=window.navigator.useragent.tolowercase(); if (str.indexof('firefox')!=-1) {//火狐浏览器 box.addeventlistener('dommousescroll',function (event){ // event.preventdefault();//阻止窗口默认的滚动事件 // console.log(event.detail);//前滚-3 if (event.detail0) { console.log('前滚'); box.style.width=box.offsetwidth+20+'px'; box.style.height=box.offsetheight+20+'px'; }; if (event.detail>0) { console.log('后滚'); box.style.width=box.offsetwidth-20+'px'; box.style.height=box.offsetheight-20+'px'; }; return false;//阻止默认事件 },false); } else{//非火狐浏览器 box.onmousewheel=function (ev){ var e=ev||window.event; /*if (e.preventdefault) { e.preventdefault(); } else{ e.returnvalue=false; };*/ // console.log(e); // console.log(e.wheeldelta);//前滚120 if (e.wheeldelta>0) { console.log('前滚'); box.style.width=box.offsetwidth+20+'px'; box.style.height=box.offsetheight+20+'px'; }; if (e.wheeldelta0) { console.log('后滚'); box.style.width=box.offsetwidth-20+'px'; box.style.height=box.offsetheight-20+'px'; }; return false;//阻止默认事件 } }; script>body>html>