HTML Event Attributes

HTML Event Attributes

If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on the screen.

There are lots of event attributes in HTML5 and programming languages, such as JavaScript.

The following is a table of event attributes allowing us to execute several events using those attributes.

Windows Event Attributes

For the window object, Windows events are linked. It can only added with < body > tag.

AttributeDescription
On-after-printAfter the document has been written, the script has executed.
On-before-printThe script has executed before imprinting a document.
On-before-unloadBefore uploading a document, she executed the script.
On-errorThe script was executed when an error occurred.
On-hash-changeWhen the anchor part in the webpage URL is changed, the script is executed.
On-massageThe script was executed when a message occurs.
On-offlineWhen the network connection is broken, the script was executed, and the browser started working offline.
On-onlineThis script was executed when the browser began operating online.
On-loadThe script was executed when the webpage is fully loaded.
On-page-hideWhen the current web page is hidden, the script is executed. It appears as if the user had moved away from the current web page.
On-page-showExecuted the script when focused primarily on the current website.
On-resizeThe script is executed when the window is resized.
On-pop-stateThe script is executed when the active history of the window is changed.
On-unloadWhen the current webpage is removed, execute the file, or the window is closed.
On-storageThe script was executed when web storage is modified.

Form Event Attributes

Form event occurs when some activities are carried out by the user within the program, such as sending the request, selecting the input field, etc.

Events of form can be used for any element, but these are primarily used for aspects of HTML form.

The following is a list of all attributes for Form Events:

AttributeDescription
OnblurThe script was executed when the form item loses focus.
OnfocusIt triggers an event when it focuses on an element.
OninputThe script is executed when the user enters the element input.
OnchangeWhen the element value is changed, the script is executed.
OnresetTriggers the event when the values for the form element are reset by the user.
On-invalidThe script was executed when the element does not fulfill its predefined constraints.
On-selectTriggers an event when any text has been selected by the user.
On-searchTriggers an event when input is received from a search field.
OnsubmitTriggers the event when a form has been submitted.

Keyboard Event Attributes

The event on the keyboard is when the user communicates with the keyboard. The Keyboard Events list below.

AttributeDescription
OnkeydownTriggers the event by pressing a key downwards on the keyboard.
OnkeypressTrigger the event by pressing the key that displays a particular character.
OnkeyupIf the user releases the currently pressed key, trigger the event.

Mouse Event Attributes

AttributeDescription
OnmousedownActivate the event when the item clicks on the mouse button.
OnmousemoveCause an event when the item is moving over the mouse pointer.
OnclickTrigger the event by clicking the mouse on the item.
On-db-clickTrigger the event when the element is double-clicked on the mouse.
OnmouseoverTrigger the event by moving the mouse on to the feature.
OnmouseoutTrigger the event by moving the mouse outside of the feature.
OnmouseupTrigger event by mouse button release.
On-wheelTrigger the event if the mouse wheel rolls, up or down, over the object.
OnmousewheelIt's deprecated. Using the onwheel attribute.

Clipboard Event Attributes

AttributeDescription
On-copyTrigger an activity when the user copies the contents into the machine clipboard.
OncutTrigger an event when the element's contents are cut into the clipboard and copied.
OnpasteTrigger the event by pasting any content into an item.

Media Event Attribute

AttributeDescription
OnabortWhen media replay is aborted, this script was executed.
OncanplayThe script was executed when a media file is ready to play.
OncanplaythroughThe script was executed when the media file is ready to play without stopping or buffering.
OndurationchangeExecute a script when the duration of the media file is changed.
OncuechangeThe text cue of the < track > element script is changed.
OnemptiedExecute a script if a media error occurs, and the file becomes unavailable.
OnendedThe script was executed when its endpoint occurs in the media file.
OnerrorThe script was executed when an error occurred while the media data was being fetched.
OnloadeddataThe script was executed while loading media data.
OnloadedmetadataThe script is executed when the media file metadata is loaded.
OnloadstartThe script was executed when loading of media file starts.
OnpauseWhen the media playback is stopped, the script is executed.
OnplayWhen after being paused, the media file is ready to play, the script is executed.
OnplayingWhen a media file is started running, the script was executed.
OnprogressThe script was executed when the user is in the process of obtaining the media info.
OnratechangeWhen the playback speed was changed, the script executed.
OnseekedWhen the search for operation is over, the script is cleared, and the feature is searched.
OnseekingWhen the search operation is active, the script executed, and the search attribute set to true.
OnstalledThe script was run when the browser suddenly stopped fetching data media.
On-suspandIf fetching media data is intentionally stopped, the script is executed.
OntimeupdateWhen the playback position is changed, the script executed as though a user fasts the track forward.
OnvolumechangeThe script is executed when the volume of media is changed (muted or unmuted).
OnwaitingIf playback is paused to wait for more data to be loaded, the script executed.