XHTML Event Attributes
- Previous Page XHTML Attributes
- Next Page Summary of XHTML
One of the new features of HTML 4.0 is to enable HTML events to trigger behaviors in the browser, such as starting a JavaScript block when a user clicks an HTML element. The following is a series of attributes that can be inserted into HTML tags to define event behaviors.
If you want to learn how to program with these events, then you should study our JavaScript Tutorial and DHTML Tutorial.
Window Events
Valid only in body and frameset elements.
Attribute | Value | Description |
---|---|---|
onload | Script | Execute script when the document is loaded |
onunload | Script | Execute script when the document is unloaded |
Form Element Events
Valid only in form elements.
Attribute | Value | Description |
---|---|---|
onchange | Script | Execute script when an element changes |
onsubmit | Script | Execute script when a form is submitted |
onreset | Script | Execute script when a form is reset |
onselect | Script | Execute script when an element is selected |
onblur | Script | Execute script when an element loses focus |
onfocus | Script | Execute script when an element gains focus |
Keyboard Events
Invalid in the following elements: base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and the title element.
Attribute | Value | Description |
---|---|---|
onkeydown | Script | Execute script when the keyboard is pressed |
onkeypress | Script | Execute script when the keyboard is pressed and then released |
onkeyup | Script | Execute script when the keyboard is released |
Mouse Events
Invalid in the following elements: base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title element.
Attribute | Value | Description |
---|---|---|
onclick | Script | Execute Script When the Mouse is Clicked |
ondblclick | Script | Execute Script When the Mouse is Double-Clicked |
onmousedown | Script | Execute Script When the Mouse Button is Pressed |
onmousemove | Script | Execute Script When the Mouse Pointer Moves |
onmouseout | Script | Execute Script When the Mouse Pointer Leaves an Element |
onmouseover | Script | Execute Script When the Mouse Pointer Hovers Over an Element |
onmouseup | Script | Execute Script When the Mouse Button is Released |
- Previous Page XHTML Attributes
- Next Page Summary of XHTML