Site hosted by Angelfire.com: Build your free website today!
JavaScript
Another Vrong © JavaScript Tutorial

Event Handler:

Now that you know the basic concepts behind the JavaScript language, we’ll need to examine a little more closely a concept of event handlers. Event Handlers are important because nothing really happens in a JavaScript program until the user initiates an action. You use event handlers to link a user to the execution of a JavaScript program.

Event handlers are embedded in documents as attributes of HTML tags. The tags are then associated with the JavaScript code that is executed when an event occurs. The general syntax for an event handler is

<Tag eventHandler="JavaScript Code" >

Tag represent some HTML tag (for instance, INPUT), eventHandler is the name given to the particular event handler, and JavaScript Code represents the name of a function that you have written in JavaScript. For example, say you defined a function called Compute. You could have Navigator perform this function when the user clicks on a button with an HTML tag that looks like this:

<INPUT TYPE="button" VALUE="Calculate" onClick="Compute(this.form)">

The event handler in this example is onClick, which calls the Compute function when the user initiates the event of clicking on a button.

Common Event Handlers
Event Occurs When Event Handler
blur User removes input focus from form element onBlur
change User changes value of text, text area or select element onChange
click User clicks on form element or link onClick
focus User gives form element input focus onFocus
load User loads a page onLoad
mouseover User moves mouse pointer over link or anchor onMouseOver
select User submits a form onSubmit
unload User exits a page unLoad


[JavaScript History] [What is JavaScript] [Using JavaScript] [JavaScript Language] [JavaScript Statements]
[JavaScript Object Model] [JavaScript Event Handler] [JavaScript Example] [JavaScript Home]
Comments & Suggestions or Send Feedback
Internet Addiction, Funny Stuff & Cricket .