HTML DOM Event Object
Event Object
The event object represents the state of the incident, such as the element in which the event occurred, the state of the keyboard key, the position of the mouse, and the state of the mouse button.
Events are often used in conjunction with functions, and functions are not executed until the event occurs!
Event Source
The element that triggered the event
Behavior that the event was detected by JavaScript
Event Example:-Mouse click-Hover over a hotspot on the page-keyboard key-Confirm form-Select an input box in the form
Event handler function
One of the new features of HTML 4.0 is the ability to enable HTML events to trigger behavior in the browser, such as starting a piece of JavaScript when the user clicks on an HTML element. Also called "Event handle" or "event listener"
Event classification
offsetx,offsety: The x-coordinate and y-coordinate of the location of the event that occurred in the coordinate system of the event source element.
Clientx,clienty: The event property returns the coordinates of the mouse pointer to the browser page (or client area) when the event is triggered ...
Screenx,screeny: event property returns the coordinates of the mouse pointer relative to the screen when an event occurs.
Preventdefault () method
Cancels the default action for the event.
Grammar:
event.preventDefault()
Stoppropagation () method
No more events are being dispatched.
The termination event is further propagated during the capture, target processing, or bubbling phase of the propagation process. After the method is called, the handler that handles the event on that node is called, and the event is no longer dispatched to the other node.
Grammar
event.stopPropagation()
Cancelbubble This property must be set to TRUE if the event handle wants to prevent the event from propagating to the containment object.
oEvent.cancelBubble=true;
HTML DOM Event Object