NEPAL | ARTICLES | KAVITAHARU | MANTHAN | COOL LINKS | GUESTBOOK | SEARCH |
|||
JAVASCRIPT NEPAL KAVITAHARU ARTICLES COOL LINKS ADD EMAIL GUESTBOOK KURAKANI FREE E-CARDS FREE SITE SUBMIT
ABOUT ME |
| ||
Function has an important role in Javascript to hold several commands together and it also facilitate the activation of an event handler. We will discuss latter about the event and event handler. Example<script language="JavaScript"> <!-- hide from older browser document.write("How are you my friend?<BR>") document.write("How are you my friend?<BR>") document.write("How are you my friend?<BR>") //--> </script> The code above is without using the function but we could have the same result with the use of function <script language="JavaScript"> <!-- hide from older browser function myFunction(){ document.write("How are you my friend?<BR>") } myFunction() myFunction() myFunction() //--> </script> Another example <script language="JavaScript"> <!-- hide from older browser function myStatus(){ window.status="Welcome to my web page" } //--> </script> <form name=form1> <input type="button" value="EXAMPLE" name="form3" onClick="myStatus()"></form> The function enables us to activate the code only when we click on the button which contain event handler onClick rather than activating by itself while loading the web page(document).
|
Home
| About Me
| Nepal
| Articles
| Kavitaharu
| Cool Links
Javascript | Add Email | Guestbook |