时间:2021-07-01 10:21:17 帮助过:3人阅读
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)) { /怿飞注:YUI 源码 BUG,ev.constructor 也可能是 MouseEvent,不一定是 Event
break;
}
c = c.caller;
}
}
return ev;
}
调用执行的是:
代码如下:
function foo(){
var e = getEvent();
alert(e);
}