Javatpoint Logo
Javatpoint Logo

XHTML Events

When you visit a website, you do things like click on text, images and hyperlinks, hover-over things, etc. These are examples of what JavaScript calls events.

We can write our event handlers in JavaScript or VBScript and can specify these event handlers as a value of event tag attribute. The XHTML 1.0 has a similar set of events which is available in HTML 4.01 specification.


The <body> and <frameset> Level Events

There are only two attributes which are used to trigger any JavaScript or VBScript code, when any event occurs at document level.

Attribute Value Description
onload Script Script runs when a XHTML document loads.
onunload Script Script runs when a XHTML document unloads.

The <form> Level Events

There are six attributes which are triggered when any event occurs at form level.

Attribute Value Description
onchange Script It is executed when the element changes.
onsubmit Script It is executed when the form is submitted.
onreset Script It is executed when the form is reset.
onselect Script It is executed when the element is selected.
onblur Script It is executed when the element loses focus.
onfocus Script It is executed when the element gets focus.

Keyboard Events

There are three events which are generated by keyboard. The keyboard events are not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.

Attribute Value Description
onkeydown Script This is executed when the user press the keyboard button.
onkeypress Script This is executed when the user press and release the keyboard button.
onkeyup Script This is executed when the user release the keyboard button.

Mouse Events

There are some mouse generated events which executes when it comes in contact with any HTML tag. These events are not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.

Attribute Value Description
onclick Script It is executed on a mouse click.
ondblclick Script It is executed on a mouse double-click.
onmousedown Script It is executed when mouse button is pressed.
onmousemove Script It is executed when mouse pointer moves.
onmouseout Script It is executed when mouse pointer moves out of an element.
onmouseover Script It is executed when mouse pointer moves over an element.
onmouseup Script It is executed when mouse button is released.
Next TopicHXHTML Doctypes





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA