Saturday, 14 September 2013

HTML Events References

When a user visit your website, they do things like click on text and images and given links, hover over things etc. These are examples of what JavaScript calls events.
We can write our event handlers in Javascript of vbscript and can specify these event handlers as a value of event tag attribute. The HTML 4.01 specification defines 19 event attributes as listed below:

<body> and <frameset> Level Events:

There are only two attributes which can be used to trigger any javascript or vbscript code when there is any event occurs on document level.
AttributeValueDescription
onloadscriptScript runs when a HTML document loads
onunloadscriptScript runs when a HTML document unloads
NOTE: Here script refer to any VBScript or JavaScript function or piece of code.

<form> Level Events:

There are following six attributes which can be used to trigger any javascript or vbscript code when there is any event occurs on form level.
AttributeValueDescription
onchangescriptScript runs when the element changes
onsubmitscriptScript runs when the form is submitted
onresetscriptScript runs when the form is reset
onselectscriptScript runs when the element is selected
onblurscriptScript runs when the element loses focus
onfocusscriptScript runs when the element gets focus

Keyboard Events

There are following three events which are generated by keyboard. These events are not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.
AttributeValueDescription
onkeydownscriptScript runs when key is pressed
onkeypressscriptScript runs when key is pressed and released
onkeyupscriptScript runs when key is released

Other Events:

There following other 7 events which are generated by mouse when it comes in contact of any HTML tag. These events are not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, title elements.
AttributeValueDescription
onclickscriptScript runs when a mouse click
ondblclickscriptScript runs when a mouse double-click
onmousedownscriptScript runs when mouse button is pressed
onmousemovescriptScript runs when mouse pointer moves
onmouseoutscriptScript runs when mouse pointer moves out of an element
onmouseoverscriptScript runs when mouse pointer moves over an element
onmouseupscriptScript runs when mouse button is released

No comments:

Post a Comment