Use the mouse wheel to trigger a scrolling event on the page's inner element-free scroll bar, which does not trigger a scrolling event for the browser window when the scrollbar reaches the top or bottom of the elements.
Implemented by calling the following function:
function Preventscroll (ID) {var_this =document.getElementById (ID); if(Navigator.userAgent.indexOf ("Firefox") >0) {_this.addeventlistener ('Dommousescroll', Function (e) {_this.scrolltop+ = e.detail >0? -: - -; E.preventdefault (); },false); }Else{_this.onmousewheel=function (e) {e= e | | Window.Event; _this.scrolltop+ = E.wheeldelta >0? - -: -; return false; }; } return This; }
Reference: http://www.cnblogs.com/weekend001/archive/2011/05/11/2043474.html
IE9 does not support similar e.returnvalue = False, the corresponding place is changed to return false.
jquery Plugin:
$.fn.extend ({"Preventscroll": function () {//Prevent scrolling$( This). each (function () {var_this = This; if(Navigator.userAgent.indexOf ('Firefox') >=0) {//Firefox_this.addeventlistener ('Dommousescroll', function (e) {E.preventdefault ();},false); } Else{_this.onmousewheel=function (e) {return false; }; } }) }, "Areascroll": function () {//zone to prevent bubbling scrolling$( This). each (function () {var_this = This; if(Navigator.userAgent.indexOf ('Firefox') >=0) {//Firefox_this.addeventlistener ('Dommousescroll', Function (e) {_this.scrolltop+ = e.detail >0? -: - -; E.preventdefault (); }, false); } Else{_this.onmousewheel=function (e) {e= e | | Window.Event; _this.scrolltop+ = E.wheeldelta >0? - -: -; return false; }; } }) }});
Block page internal ScrollBar MouseWheel event bubbling