Home > Web Front-end > JS Tutorial > How to use the Event object of JS_javascript skills

How to use the Event object of JS_javascript skills

WBOY
Release: 2016-05-16 18:14:25
Original
1404 people have browsed it

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

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);
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template