Home >
Web Front-end >
JS Tutorial >
Summary of event object acquisition methods tested under Google browser_javascript skills
Summary of event object acquisition methods tested under Google browser_javascript skills
WBOY
Release: 2016-05-16 17:17:58
Original
1136 people have browsed it
Introduction:
The Event object represents the state of the event, such as the element in which the event occurred, the state of the keyboard keys, the position of the mouse, and the state of the mouse button. Events are often used in conjunction with functions, which are not executed until the event occurs! Getting method of Event object:
var e = arguments.callee.caller.arguments[0] || window.event;
/ /arguments.callee refers to the current function body
//arguments.callee.caller is the superior function of the current function
//So when onclick="demo2()" is executed, arguments .callee is demo2(), arguments.callee.caller is function onclick, //The first function of onclick is event, which is arguments.callee.caller.arguments[0].
}
Detailed test summary:
One: The same universal method is to pass the parameter event (the actual parameter must be written as event and other names will not work).
Two: window.event is suitable for IE and Google browsers and Firefox does not support it.
Three: arguments.callee.caller.arguments[0] is only supported by Firefox and Google. IE does not support this acquisition method.
From the above test results, it can be seen that Google Chrome supports the above various acquisition methods and is the most compatible browser.
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