网上搜来的,看样子不错,记一笔。//---------------------- -
// Quirksmode addEvent 콘테스트 우승자 John Resig
//addEvent
함수 addEvent(obj,type,fn){
if(obj.addEventListener) obj.addEventListener(type을 기반으로 함) ,fn,거짓);
else if(obj.attachEvent){
obj["e" type fn]=fn;
obj[type fn]=function(){obj["e" type fn](window.event);}
obj.attachEvent("on" type,obj[type fn]);
}
}
//----------------------------------- --
// removeEvent
function removeEvent(obj,type,fn){
if(obj.removeEventListener) obj.removeEventListener(type,fn,false);
else if(obj.detachEvent){
obj.detachEvent("on" type,obj[type fn]);
obj[type fn]=null;
obj["e" type fn]=null;
}
}