XHTML - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

XHTML Events

XHTML Events

shape Introduction

The chapter demonstrates about the XHTML Events which are used to perform any action on JavaScript or VBScript code given in XHTML application following are the concepts covered.
  • Body Events
  • Keyboard Events
  • Form Events
  • Other Events

Body Events

shape Description

Body Event attributes are used for trigger VBScript or JavaScript code if any event occur at document level there are only two attributes in Body events which are listed below.
Attributes Value Description
onload Script If XHTML Documents start loading then script start running.
onunload Script If XHTML Documents start unloading then script start running.
In the above table script refers to the function or snippet of the JavaScript or VBScript.

Keyboard Events

shape Description

All key events will performed in keyboard events and following are the some events are not valid in br, base, bdo, html, frameset, head, meta, param, iframe, style, title, and script elements. Following are the some events of keyboard listed.
Attributes Value Description
onkeydown Script Get into action when pressing a key.
onkeypress Script Get into action when press a key.
onkeyup Script Get into action when release a key.

Form Events

shape Description

Form events performed some actions by triggering form elements inside HTML document. The image below demonstrates the some attributes. Following are six attributes are listed below.
Attributes Value Description
onchange Script If the element get any changes then the script will runs.
onreset Script If the form get reset then script will execute.
onsubmit Script When the form get submitted then script will execute.
onblur Script When the element get looses focus then script will executs.
onselect Script When the form get selected then script will execute.
onfocus Script When the form get focused then script will runs.

Other Events

shape Description

Following are the some events which are generated with mouse when it is comes together with the HTML . There are some events which are not validate in br, base, frameset, bdo, html, iframe, head, script, meta, style, param, and title elements. some events are listed below.
Attributes Value Description
onclick Script Gets into action when clicked on the element.
ondblclick Script Get into action when double clicked on the element.
onmousemove Script Get into action when the mouse moved on the element.
onmousedown Script Get into action when the mouse button pressed down.
onmouseover Script Get into action when the mouse moved on an element.
onmouseout Script Get into action when the mouse moved out of an element.
onmouseup Script Get into action when the mouse released over an element.
The code below demonstrates the XHTML events as shown. [html] <html> <input type="text" name="name" onblur="Validate()"> <br /> <br /> <input type="text" name="name" onchange="Validate()"> <br /> <br /> <select name="Countries" onchange="Validate()"> <option value="0">Select</option> <option value="1">India</option> <option value="2">US</option> <option value="3">UK</option> <option value="4">Australia</option> </select> <br /> <br /> <input type="text" name="name" onfocus="Validate()"> <br /> <br /> <input type="text" name="name" onkeydown="Validate()"> <br /> <br /> <input type="text" name="name" onkeypress="Validate()"> <br /> <br /> <input type="text" name="name" onkeyup="Validate()"> </html> [/html] Result By running the above code in a preferred browser user can get the following output as shown in below image.

Summary

shape Key Points

  • Every event perform some operations on document.
  • Windows events will use only in body tags.
  • Form events will perform some actions on forms.