function addEventHandler(elm,eventType,handler){ elm=typeof elm=="string"?document.getElementById(elm):elm; if(elm.attachEvent){ elm.attachEvent("on"+eventType,handler); }else if(elm.addEventListener){ elm.addEventListener(eventType,handler,false); }else return false; }
//绑定事件 --解决this的指向问题(冯总) 暂时不理解是什么意思,在哪里能用到 CBTC.Cevent.addDomEvent = function(elem, type, fn){ if(elem.attachEvent){ var typeRef = "_" + type; if(!elem[typeRef]){ elem[typeRef] = []; } for(var i in elem[typeRef]){ if(elem[typeRef][i] == fn){ return; } } elem[typeRef].push(fn); elem["on"+type] = function(){ for(var i in this[typeRef]){ this[typeRef][i].apply(this,arguments); } } }else{ elem.addEventListener(type,fn,false); } };