ncthakur.itgo.com     Javascript: Use of Function

         NEPAL     |     ARTICLES     |     KAVITAHARU    |     MANTHAN    |     COOL LINKS    |     GUESTBOOK    |     SEARCH

JAVASCRIPT
As I have learned as a beginner:
1. Opening New Window

2. Use of Alert, Prompt & Confirm

3. Document Write

4. Use of Function

5. Event Handlers (Image Rollover)

6. If and Else Statement

7. Predefined Object (Date)

8. Cut & Paste JavaScript

NEPAL
Overview of Nepal
Map & images
Nepalese websites

KAVITAHARU
View few of my poems
written in Nepali language

ARTICLES
Articles on
crime prevention
investigation
& crime control

COOL LINKS
Computer
Travel & Tour
Police World
Downloads
Personality Test
Nepal News
Crime & Police News
Nepali Music
Health
Horoscope
Monthly Poll
Other

ADD EMAIL
Search or add email to the search list.

GUESTBOOK
View to find out what other visitors have to say about this web site.

KURAKANI
Are you interested to chat? Go to Kurakani room.

FREE E-CARDS
Enormous free E-Cards of your choice. Send it to your friend and family members.

FREE SITE SUBMIT
Submit your web site to the major search engines here.

ABOUT ME
Click here to find out about me and view few of my photographs.

 

Use of Function

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).

BACK

NEXT..........


Top

Home  | About Me  |  Nepal  |  Articles  | Kavitaharu  | Cool Links 
 Javascript  | Add Email  |  Guestbook