Comment: HTML elements can have event attributes that trigger behavior in the browser, such as starting a JavaScript when a user clicks an HTML element. The event properties listed below can be inserted into HTML tags to define event behavior. Differences between HTML 4.01 and HTML 5 New events in HTML 5: onabort, onbeforeunload, onconte
HTML elements can have event attributes that trigger behavior in the browser, such as starting a JavaScript when a user clicks an HTML element. The event properties listed below can be inserted into HTML tags to define event behavior.
Differences between HTML 4.01 and HTML 5
New events in HTML 5: onabort, onbeforeunload, oncontextmenu, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onmessage, onmousewheel, onresize, onscroll, onunload.
HTML 4.01 attributes that are no longer supported: onreset.
property
Attribute value description 45
Run the script when the abort event occurs onaborscript. 5
onbeforeonloadscript runs the script before the element is loaded. 5
onblurscript runs script when the element loses focus. 45
onchangescript runs the script when the element changes. 45
onclickscript allows scripts when the mouse clicks. 45
oncontextmenuscript runs the script when the menu is triggered. 5
ondblclickscript Run the script when the mouse is double-clicked. 45
ondragscript allows scripts as long as the script is dragged. 5
ondragendscript runs the script at the end of the drag operation. 5
ondragenterscript Executes the script when the element is dragged to a legal placement target. 5
ondragleavescript When an element leaves the legal placement target. 5
ondragoverscript executes the script as long as the element is dragging on the legal placement target. 5
ondragstartscript executes scripts when the drag operation starts. 5
ondropscript Executes script when an element is being dragged. 5
onerrorscript executes script when an error occurs during element loading. 5
onfocusscript executes script when an element gets focus. 45
onkeydownscript executes script when the button is pressed. 45
onkeypressscript executes script when the key is pressed. 45
onkeyupscript executes script when the button is released. 45
onloadscript executes scripts when the document is loaded. 45
onmessagescript executes script when the message event is triggered. 5
onmousedownscript executes script when the mouse button is pressed. 45
onmousemovescript executes scripts when the mouse pointer moves. 45
onmouseoverscript executes script when the mouse pointer moves to an element. 45
onmouseoutscript executes script when the mouse pointer moves out of the element. 45
onmouseupscript executes script when the mouse button is released. 45
onmousewheelscript executes scripts when the mouse wheel scrolls. 5
onresetscript executes script when form resets. Not supported. 4
onresizescript runs the script when the element is resized. 5
onscrollscript executes script when the element scrollbar is scrolled. 5
onselectscript executes the script when the element is selected. 45
onsubmitscript runs script when form is submitted. 45
onunloadscript runs script when the document is unloaded. 5