function addEvent(obj, type, handle) { if (obj.addEventListener) { obj.addEventListener(type, handle); } else if (obj.attachEvent) { obj.attachEvent('on' + type, handle); } } function removeEvent(obj, type, handle) { if (obj.removeEventListener) { obj.removeEventListener(type, handle); } else if (obj.detachEvent) { obj.detachEvent('on' + type, handle); } }