日期:2014-05-16 浏览次数:20335 次
/** * 系统事件. */ _sysEvent:function(){ var _this = this; /** * 事件列表 */ this._eventList = { mouseup:function(ev) { var ev = ev || window.event; _this._docMouseUp(ev); }, mousedown:function(ev) { var ev = ev || window.event; _this._docMouseDown(ev); }, mousemove:function(ev) { var ev = ev || window.event; _this._docMouseMove(ev); }, keyup:function(ev) { var ev = ev || window.event; return _this._docKeyUp(ev); }, keydown:function(ev) { var ev = ev || window.event; return _this._docKeyDown(ev); }, mousewheel:function(ev) { var ev = ev || window.event; var re = _this._docMouseWheel(ev); if(re) { evt = ev || window.event; if(evt.preventDefault) { // Firefox evt.preventDefault(); evt.stopPropagation(); } else { // IE evt.cancelBubble=true; evt.returnValue = false; } return false } return true; } }; if (window.addEventListener) { // 其它浏览器的事件代码: Mozilla, Netscape, Firefox // 添加的事件的顺序即执行顺序 // 注意用 addEventListener 添加带on的事件,不用加on document.addEventListener("mousedown", this._eventList.mousedown, false); document.addEventListener("mouseup", this._eventList.mouseup, false); document.addEventListener("mousemove", this._eventList.mousemove, false); document.addEventListener("keydown", this._eventList.keydown, false); document.addEventListener("keyup", this._eventList.keyup, false); document.addEventListener('DOMMouseScroll', this._eventList.mousewheel,false); //chrome document.addEventListener('mousewheel', this._eventList.mousewheel,false); } else { // IE 的事件代码 在原先事件上添加 add 方法 document.attachEvent("onmousedown", this._eventList.mousedown); document.attachEvent("onmouseup", this._eventList.mouseup); document.attachEvent("onmousemove", this._eventList.mousemove); document.attachEvent("onkeydown", this._eventList.keydown); document.attachEvent("onkeyup", this._eventList.keyup); document.attachEvent("onmousewheel", this._eventList.mousewheel); } }, /** * 清除系统事件. */ clearEvent:function() { if (window.removeEventListener) { // 其它浏览器的事件代码: Mozilla, Netscape, Firefox // 添加的事件的顺序即执行顺序 // 注意用 addEventListener 添加带on的事件,不用加on document.removeEventListener("mousedown", this._eventList.mousedown, false); document.removeEventListener("mouseup", this._eventList.mouseup, false); document.removeEventListener("mousemove", this._eventList.mousemove, false); document.removeEventListener("keydown", this._eventList.keydown, false); document.removeEventListener("keyup", this._even