Copy Code code as follows:
/**
* @description event bindings, compatible with each browser
* @param target Event Trigger object
* @param type Event
* @param Func event handler function
*/
function addevents (target, type, func) {
if (Target.addeventlistener)//non IE and IE9
Target.addeventlistener (Type, func, false);
else if (target.attachevent)//ie6 to IE8
Target.attachevent ("On" + Type, func);
else target["on" + type] = func; Ie5
};
Copy Code code as follows:
/**
* @description event removed, compatible with each browser
* @param target Event Trigger object
* @par AM Type Event
* @param func event handler
/
function removeevents (target, type, func) {
if (target.removeeve Ntlistener)
Target.removeeventlistener (Type, func, false);
Else if (target.detachevent)
Target.detachevent ("on" + Type, func);
Else target["on" + type] = NULL;
};