Add or delete events using attachEvent and detachEvent in IE browser. In other standard browsers, addEventListener and removeEventListener are used. The following encapsulates the addition and deletion of events. Check the Code directly!
/*** @ Description event binding, compatible with various browsers * @ param target * event trigger object * @ param type * event * @ param func * event processing function */function bind (target, type, func) {if (target. addEventListener) {// non-ie and ie9target. addEventListener (type, func, false);} else if (target. attachEvent) {// ie6 to ie8target. attachEvent ("on" + type, func);} else {target ["on" + type] = func; // ie5}/*** @ description event removed, compatible with various browsers * @ param target * event trigger object * @ param type * event * @ param func * event processing function */function unbind (target, type, func) {if (target. removeEventListener) {target. removeEventListener (type, func, false);} else if (target. detachEvent) {target. detachEvent ("on" + type, func);} else {target ["on" + type] = null ;}}