Exforsys.com
 
Home Tutorials JavaScript
 

JavaScript Event Handler

 

JavaScript Event Handler

In this JavaScript tutorial, you will learn about using event handlers along with events for each HTML tag.



Using Event Handler in JavaScript:

Event Handlers are used in JavaScript by placing the name of the event handler inside the HTML tag associated with object. This is followed by =’JavaScript code’, the code in JavaScript which must execute when the event fires.


The events for each HTML tag are as follows:


<A>


click (onClick)
mouseOver (onMouseOver)
mouseOut (onMouseOut)


<AREA>


mouseOver (onMouseOver)
mouseOut (onMouseOut)


<BODY>


blur (onBlur)
error (onError)
focus (onFocus)
load (onLoad)
unload (onUnload)


<FORM>


submit (onSubmit)
reset (onReset


<FRAME>


blur (onBlur)
focus (onFocus)


<FRAMESET>


blur (onBlur)
error (onError)
focus (onFocus)
load (onLoad)
unload (onUnload)


<IMG>


abort (onAbort)
error (onError)
load (onLoad)


<INPUT TYPE = "button">


click (onClick)


<INPUT TYPE = "checkbox">


click (onClick)


<INPUT TYPE = "reset">


click (onClick)


<INPUT TYPE = "submit">


click (onClick)


<INPUT TYPE = "text">


blur (onBlur)
focus (onFocus)
change (onChange)
select (onSelect)


<SELECT>


blur (onBlur)
focus (onFocus)
change (onChange)


<TEXTAREA>


blur (onBlur)
focus (onFocus)
change (onChange)
select (onSelect)


For example, consider a button placed in a form named PressButton. The following code placed in the click event of the button named PressButton would be written:



<
input type="button"
name="PressButton"
value="
Press the Button to output value!!!"
onClick="outputvalue();">




In the above example, when the user clicks the button, the onclick event of the button fires and the message assigned to value displays:


Press the Button output value!!!


The block of code written in the function outputvalue() in JavaScript fires or calls.



Read Next: JavaScript Exception Handling – Part I



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape