1 /**
  2  * 阻止鼠标滑轮滑动
  3  * @constructor
  4  * @name vui.preventScroll
  5  * @author putaoshu@126.com
  6  * @date 2012-05-14
  7  * @example vui.preventScroll.init();
  8  */
  9 
 10 vui.preventScroll={
 11 	 /** @lends vui.preventScroll*/
 12 	//mousewheel事件:兼容FF
 13 	mousewheelEvent : (/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel",
 14 	isIE: document.attachEvent ? true : false,
 15 	/**
 16 	 * 初始化
 17 	 * @name vui.preventScroll.init
 18 	 */
 19 	init:function(){
 20 		if(this.isIE){ 
 21 			document.attachEvent("on" + this.mousewheelEvent,this.handler,false);
 22 		}else{ 
 23 			document.addEventListener(this.mousewheelEvent,this.handler,false);
 24 		}
 25 	},
 26 	/**
 27 	 * 移除阻止事件
 28 	 * @name vui.preventScroll.destroy
 29 	 */
 30 	destroy:function(){
 31 		if(this.isIE){ 
 32 			document.detachEvent("on" + this.mousewheelEvent,this.handler,false);
 33 		}else{
 34 			document.removeEventListener(this.mousewheelEvent,this.handler,false);
 35 		}
 36 	},
 37 	handler:function(event){
 38 		if(vui.preventScroll.isIE){
 39 			event.returnValue = false;
 40 		}else{
 41 			event.preventDefault();
 42 		}
 43 	}
 44 }
 45 
 46