×

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.

Related Topics

HTML References

BASIC HTML TAGS TAGS DESCRIPTION <!DOCTYPE> Defines Document Type <html> Defines Html document <head> Defines Header of document <title> Defines Title of document <body> Describe all the content of document <h1> to <h6> Defines Html Heading <p> Write Paragraph in this tag <br> Line break <!--...--> Comment in Html FORMATTING TAGS TAGS DESCRIPTION <abbr> Defines...

3 minutes read.

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...

4 minutes read.

How to insert spaces/tabs in text using HTML/CSS

What is HTML? HTML or HyperText Markup Language is used to design web pages. It was released in 1993. The file extension name for HTML file is “.html”. An HTML file...

4 minutes read.

How to insert image in HTML

An image (technically digital image) in HTML or even in general technical aspects is a binary representation of visual information. By visual information we mean, in the form of drawings/pictures,...

5 minutes read.

HTML Form Input Types

HTML Form Input Types An important element of the HTML form is < input type= "> in HTML. The type attribute of the input element can be of different types, which...

8 minutes read.

HTML Font Size

The HTML <font> tag uses the size attribute to specify the size of the text. We can set the size attribute’s value from 1 to 7. The default size of...

4 minutes read.

HTML Hide Element

The HTML hide element is used to hide the element. We place the hidden attribute inside those elements which we want to hide. The hidden attribute is a Boolean attribute. The...

3 minutes read.

HTML Attributes

HTML Attributes provide the additional information about HTML elements. Attributes are always specified in the start tag. Attributes usually comes in pairs. lang Attribute This attribute helps in declaring the language...

2 minutes read.

HTML Form Action

The <form> tag has an attribute named action that contains a URL. The HTML action attribute defines the webpage URL on which you want to send the data after submitting...

4 minutes read.

HTML Paragraphs

In html, there are some elements which starts with new line and one of them is paragraph. Which is said to be a block of text. In html <p> tag...

4 minutes read.

HTML <samp> tag

The Samp tag in HTML is used for defining the sample output from the computer program. This tag is a phrase type tag and a container tag that means the...

2 minutes read.

HTML Charsets

In this tutorial, we are going to discuss about the charsets in the HTML. The letters, numbers, and several other symbols are shown correctly by the web browser. All of this...

2 minutes read.

HTML Id Attribute

The HTML id attribute represents the unique identifier for an element of the HTML document. Each element has its unique identifier. The id attribute is a global attribute that can be...

12 minutes read.

Caption Tag in HTML

Caption Tag in HTML: The < caption > tag in HTML describes the heading of a table in the HTML text. Browsers typically make the text found above the table...

4 minutes read.

HTML Code

Before jumping into the topic, let’s understand a common scenario where we have a code snippet in our HTML file. By code snippet, we mean computer code, which is written...

5 minutes read.

HTML Basic Tags

Heading Tags: This tag represents the document header. It is said to be a good practice if every document starts with Heading. Heading tags ranges from H1 to H6 i.e....

3 minutes read.

Html <colgroup> Tag

A HTML table's column group is specified by the "colgroup" tag. If you want to apply various properties to one or more <col> elements in an HTML table, then you...

4 minutes read.

HTML <svg> tag

SVG is used to determine the vector-based graphics in XML format. What is SVG? We utilize SVG tag to specify visuals for the website. The attribute of SVG in a HTML document...

2 minutes read.

HTML &lt;blink> Tag

In HTML, the blink tag is used to create the text which flashes. The blink tag is an inline element in HTML. It is observed that the blink tag used...

2 minutes read.

Difference between HTML and DHTML

Introduction to HTML HTML stands for Hypertext Markup Language. It is a standard web language used to create web pages and applications. HTML is used to define the structure and content...

4 minutes read.