]
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);
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn