<ptml> <pead> <title></title> </pead> <body> <div id= "CONTENTQ" onclick= bb (Ev ENT) "><!--display incoming event object--> fasdf </div> </body> <script type=" text/javascript "> Function bb ( e) {alert (e); var container = document.getElementById ("CONTENTQ"); Container.onclick=function (e) {if (document.all) {//ie var a=window.event; alert (A.type); }else{alert (E.type); }} </script> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Event objects to obtain a unified approach: (from Network)
Copy Code code as follows:
function GetEvent (event) {
var ev = Event | | window.event;
if (!ev) {
var c = This.getEvent.caller;
while (c) {
EV = C.arguments[0];
if (ev && Event = Ev.constructor | | MouseEvent = = Ev.constructor)) {/Yiwen Fei Note: YUI source bug,ev.constructor may also be mouseevent, not necessarily an Event
Break
}
c = C.caller;
}
}
return EV;
}
The call executes the following:
Copy Code code as follows:
function foo () {
var e = getEvent ();
Alert (e);
}