]
Event object obtains a unified method : (from the Internet)
The code is 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)) { /Yi Fei Note: YUI source code BUG, ev.constructor may also be MouseEvent, not necessarily Event
break;
}
c = c.caller;
}
}
return ev;
}
The call executes:
The code is as follows:
function foo(){
var e = getEvent ();
alert(e);
}