标签:style blog color io ar div cti log sp
function addEvent(obj,type,fn){ if(obj.addEventListener){ obj.addEventListener(type,fn,false); }else if(obj.attachEvent){ obj.attachEvent(‘on‘+type,function(){ fn.call(this); }); } } function removeEvent(obj,type,fn){ if(obj.removeEventListener){ obj.removeEventListener(type,fn,false); }else if(obj.detachEvent){ obj.detachEvent(‘on‘+type,fn); } } function preDef(evt){ var e = evt || window.event; if(e.preventDefault){ e.preventDefault(); }else{ e.returnValue = false; } } //跨浏览器获取目标对象 function getTarget(evt){ if(evt.target){ return evt.target; }else if(window.event.srcElement){ return window.event.srcElement; } } //跨浏览器获取字符编码 function getCharCode(evt){ var e = evt || window.event; if(typeof e.charCode == ‘number‘){ return e.charCode; }else{ return e.keyCode; } }
标签:style blog color io ar div cti log sp
原文地址:http://www.cnblogs.com/oceanden/p/3937848.html