The event object is an object that the DOM provides more detailed information about the event, which is often used when defining event handlers, and in order to ensure that we get an event object that is not NULL, we need to first confirm that:
1 if (! 2 e = window. Event;
Its commonly used properties are: Event.target (objects that appear as elements, such as anchors, are represented in some browsers with Event.srcelement), Event.which (the key code (Unicode representation) of the keyboard event, often used with String.fromCharCode, is represented in some browsers with Event.keycode), Event.button (the mouse button pressed, the left button is 0 or 1, Right-click 2), Event.altkey, etc.;
In order to be compatible with different browsers, we use properties with different names as follows:
Whichlink = (e.target)? E.target.id:e.srcelement.id;
First determine which one is defined and then used
The event object for JavaScript