/eventutil.js var eventutil = new Object;
/*
This method is used to add an event to a specific object, Otarget is the specified object, Seventtype is the event type, such as Click, KeyDown, and so on, Fnhandler is the event callback function
/*
Eventutil.addeventhandler = function (Otarget, Seventtype, Fnhandler) {
Firefox case
if (Otarget.addeventlistener) {
Otarget.addeventlistener (Seventtype, Fnhandler, false);
}
IE under
else if (otarget.attachevent) {
Otarget.attachevent ("on" + Seventtype, Fnhandler);
}
else {
Otarget["on" + seventtype] = Fnhandler;
}
};
/*
This method is used to remove a specific event for a particular object, Otarget is the specified object, Seventtype is the event type, such as Click, KeyDown, and so on, Fnhandler is the event callback function
/*
Eventutil.removeeventhandler = function (Otarget, Seventtype, Fnhandler) {
if (Otarget.removeeventlistener) {
Otarget.removeeventlistener (Seventtype, Fnhandler, false);
else if (otarget.detachevent) {
Otarget.detachevent ("on" + Seventtype, Fnhandler);
} else {
Otarget["on" + seventtype] = null;
}
};
/*
Format the event, which provides a consistent event by using this method because of the different ways that IE and other browsers can get events and the properties of events
*/
Eventutil.formatevent = function (oevent) {
Isie and Iswin refer to a JS file to determine the browser and operating system type
if (Isie && iswin) {
Oevent.charcode = (Oevent.type = = "KeyPress")? oevent.keycode:0;
IE only supports bubbling and does not support capture
Oevent.eventphase = 2;
Oevent.ischar = (Oevent.charcode > 0);
Oevent.pagex = Oevent.clientx + document.body.scrollLeft;
Oevent.pagey = Oevent.clienty + document.body.scrollTop;
To block the default behavior of an event
Oevent.preventdefault = function () {
This.returnvalue = false;
};
Convert Toelement,fromelement to Standard Relatedtarget
if (Oevent.type = = "Mouseout") {
Oevent.relatedtarget = oevent.toelement;
else if (Oevent.type = = "MouseOver") {
Oevent.relatedtarget = oevent.fromelement;
}
Cancel bubbling
Oevent.stoppropagation = function () {
This.cancelbubble = true;
};
Oevent.target = oevent.srcelement;
Add event occurrence time attribute, ie does not
Oevent.time = (new Date). GetTime ();
}
return oevent;
} ;
Eventutil.getevent = function () {
if (WI