XHTML Events

 

When you go to a website, you can click on text, images, and links, move your mouse over things, and so on. These are examples of events in JavaScript.

We can write our event handlers in either JavaScript or VBScript, and we can use the value of the event tag attribute to point to these event handlers. The events in XHTML 1.0 are the same as those in the HTML 4.01 specification.

The <body> and <frameset> Level Events

There are only two attributes that can be used to run any JavaScript or VBScript code when a document-level event happens.

Attribute Value Description
onload Script When an XHTML file loads, a script runs.
onunload Script
When an XHTML document stops loading, a script is run.

The <form> Level Events

There are six attributes that happen whenever any event at the form level happens.

Attribute Value Description
onchange Script When the element changes, the code is run.
onsubmit Script
It is carried out when the form is sent.

onreset Script Whenever the form is cleared, it is run.
onselect Script Whenever the element is chosen, the code is run.
onblur Script When the element loses attention, it is activated.
onfocus Script When the element receives focus, the code is run.

Keyboard Events

There are three things that can happen when you use the keyboard. The keyboard events are not allowed in the base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.

Attribute Value Description
onkeydown Script Once the user presses and releases the corresponding key on the keyboard, this action is carried out.
onkeypress Script When the finger is lifted off the keyboard, something occurs.
onkeyup Script This is executed when the user release the keyboard button.

Mouse Events

There are some mouse-driven events that run when the mouse touches an HTML tag. These events are not allowed in the base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.

Attribute Value Description
onclick Script A single click of the mouse to execute code.
ondblclick Script A mouse double-click to execute code..
onmousedown Script when mouse button is pressed to execute code..
onmousemove Script When mouse pointer moves to execute code..
onmouseout Script When mouse pointer moves out of an element to execute code..
onmouseover Script When mouse pointer moves over an element to execute code..
onmouseup Script When mouse button is released to execute code..
Related Posts
XHTML Tutorial

The XHTML tutorial explains both the basics and more advanced ideas about XHTML. Our XHTML tutorial is made for both Read more

About XHTML

  EXtensible HyperText Markup Language is what XHTML is short for. It is a mix of the HTML language and Read more

Doctypes in XHTML

  Descriptions of Document Types come in three flavours (DTDs). The XHTML Transitional standard is the most user-friendly and widespread. Read more

Attributes of XHTML

  Some XHTML attributes are the same for all XHTML tags and go with them. There are three different kinds Read more

Syntax of XHTML

The syntax of XHTML is substantially similar to that of HTML, and all valid HTML components are likewise valid in Read more

How to Disable a Link Using CSS Styling Links

How to visually hide an element with CSS? What is the purpose of the hidden attribute in HTML? How to Read more

Scroll to Top