One of the new features of HTML 4.0 is the ability to make HTML events trigger behavior in the browser, such as starting a JavaScript when a user clicks on an HTML element. Below is a list of properties that can be inserted into HTML tags to define the behavior of events.
| property | When did this event happen... |
|---|---|
| onabort | The loading of the image is interrupted. |
| onblur | The element loses focus. |
| onchange | The content of the domain is changed. |
| onclick | The event handle called when the user clicks on an object. |
| ondblclick | The event handle called when the user double-clicks an object. |
| onerror | An error occurred while loading a document or image. |
| onfocus | Elements gain focus. |
| onkeydown | A keyboard key is pressed. |
| onkeypress | A keyboard key is pressed and released. |
| onkeyup | A keyboard key is released. |
| onload | A page or image is loaded. |
| onmousedown | The mouse button is pressed. |
| onmousemove | The mouse is moved. |
| onmouseout | Mouse is removed from an element. |
| onmouseover | Move the mouse over an element. |
| onmouseup | The mouse button is released. |
| onreset | The reset button is clicked. |
| onresize | The window or frame is resized. |
| onselect | The text is selected. |
| onsubmit | The confirmation button is clicked. |
| onunload | User exit page. |
Mouse/Keyboard Properties
| property | describe |
|---|---|
| altKey | Returns whether "ALT" is pressed when the event is triggered. |
| button | Returns which mouse button is clicked when the event is triggered. |
| clientX | Returns the horizontal coordinates of the mouse pointer when the event is triggered. |
| clientY | Returns the vertical coordinate of the mouse pointer when the event is triggered. |
| ctrlKey | Returns whether the "CTRL" key is pressed when the event is triggered. |
| metaKey | Returns whether the "meta" key is pressed when the event is triggered. |
| relatedTarget | Returns the node associated with the target node of the event. |
| screenX | Returns the horizontal coordinates of the mouse pointer when an event is triggered. |
| screenY | Returns the vertical coordinate of the mouse pointer when an event is triggered. |
| shiftKey | Returns whether the "SHIFT" key is pressed when the event is triggered. |
Common HTML elements events:
onclick,
ondblclick (double click),
onkeydown (key press),
onkeypress (click the key),
onkeyup (key release),
onmousedown (mousedown),
onmousemove (mousemove),
onmouseout (mouse exits element range),
onmouseover (mouse over to element range),
onmouseup (mouse button release),
oncontextmenu (triggered when right-clicking the browser to display the "right-click menu")
The above is all about this article, I hope you like it.