Maison > Article > interface Web > javascript之卸载鼠标事件的代码_javascript技巧
//by xmg
<script> <BR>function addEvent(obj,eventName,eventFunc){ <BR> if(obj.attachEvent) { <BR> obj.attachEvent(eventName,eventFunc); <BR> }else if(obj.addEventListener){ <BR> eventName = eventName.toString().replace(/on(.*)/i,'$1'); <BR> obj.addEventListener(eventName,eventFunc,true); <BR> } <BR>} <BR>function delEvent(obj,eventName,eventFunc){ <BR> if(obj.detachEvent) <BR> obj.detachEvent(eventName,eventFunc) <BR> else if(obj.removeEventListener){ <BR> eventName = eventName.toString().replace(/on(.*)/i,'$1'); <BR> obj.removeEventListener(eventName,eventFunc,true); <BR> } <BR>} <BR></script>