Because EV is the parameter of the event! The EV contains the parameters of the event trigger, such as the EV with the Click event. E.pagex,e.pagey, KeyDown event contains Ev.keycode, etc., in IE, Ev is the global can be obtained through window.event, in other browsers are passed as parameters.
So many of the event functions are written like this:
Mydiv.onclick = function (EV) {
if (!ev) {ev = window.event;}//This sentence can also be written as: ev=window.event| | Ev
Alert (ev.pagex+ "," +ev.pagey);
}
When will JS use var oevent=ev| | The event?????
var oevent=ev| | Event
This sentence is written to be compatible with each browser,
In the Firefox browser, the event-bound function gets to the event itself and needs to be passed in from the function, while browsers such as IE can use event or window.event to get the events themselves.
The purpose of this sentence: it is necessary to obtain information about the event and to use it. Such as:
Get keys pressed or bounced by the keyboard
Gets the position coordinates of the mouse
Get the elements of a departure change event
Get Event name
Get the current propagation phase of an event
Gets the date time that the event was generated
As for the above how to obtain, you can fill in the JS event related functions and properties.
Example:
<div id= "dd" > </div>
O=document.getelementbyid ("DD");
O.onclick=function (EV) {
var oevent=ev| | Event
alert (Oevent.screenx);
}
Why is there a parameter (EV) inside the JS event function?