Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Untitled Document </title>
<body>
<input id= "Butt" type= "button" value= "Submit"/>
</body>
<script type= "Text/javascript" >
var eventutil = {};
Eventutil.formatevent = function (oevent) {
if (window. ActiveXObject) {
The CharCode property of the event, the Unicode value of the pressed key
Oevent.charcode = (Oevent.type = = ' KeyPress ')? oevent.keycode:0;
Eventphase properties for the event of the Consortium
The phase of the event, which may have one of the following values:
0-Capture phase
1-On the target
2-bubbling phase
Oevent.eventphase = 2;
The Ischar property of the event, which indicates whether the pressed key has a character associated with it
Oevent.ischar = (Eventutil.charcode > 0);
The Pagex property of the event, the x-coordinate of the mouse relative to the page
Oevent.pagex = Oevent.clientx + document.body.scrollLeft;
The Pagey property of the Web event, the y-coordinate of the mouse relative to the page
Oevent.pagey = Oevent.clienty + document.body.scrollTop;
Preventdefault method of the event, blocking the default behavior of events
Oevent.preventdefault = function () {
This.returnvalue = false;
};
The Relatedtarget property of the common event, the second target of events, often used for mouse events
if (Oevent.type = = ' Mouseout ') {
Oevent.relatedtarget = oevent.toelement;
}else if (Oevent.type = = ' MouseOver ') {
Oevent.relatedtarget = oevent.fromelement;
}
Stoppropagation method for the event of the consortium, canceling the bubbling event
Oevent.stoppropagation = function () {
This.cancelbubble = true;
};
Target attribute of the Consortium event
Oevent.target = oevent.srcelement;
The timestamp property of the consortium event, creates the current time, and returns the number of milliseconds
Oevent.time = (new Date ()). GetTime ();
}
return oevent;
};
Eventutil.getevent = function () {
if (window.event) {
Return event object under IE
Return this.formatevent (window.event);
}else{
Return event object under the Consortium
return eventutil.getevent.caller.arguments[0];
}
};
document.getElementById (' butt '). onclick = function () {
var oevent = eventutil.getevent ();
alert (oevent);
};
</script>