ncthakur.itgo.com  Javascript: Alert, Confirm & Prompt

         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 Alert, Confirm and Prompt

As I have mentioned that JavaScript treats window as an object which has properties and method to access.

Window(PROPERTIES): document, bgcolor, fgcolor, default status, frame, parent, referrer, lastmodified, history, location, name etc.

Window (
METHODS): alert, prompt, confirm, write, writeln, close, open, setTimeout, reload, clearTimeout, blur, focus etc.

Using ALERT method
<script language="JavaScript">
<!-- hide from older browser
alert("Welcome my friend")
//-->
</script>
In this example a dialogue box will be displayed which will contain the message-Welcome my friend.


Using CONFIRM method
<script language="JavaScript">
<!-- hide from older browser
var answer=confirm("jump to another javascript page")
if(answer)
window.location="js03.htm"
//-->
</script>

In this example, an interactive dialogue box will be displayed with the message-jump to another javascript page. If you click OK you will be taken to that page because the window.location is addressed to that place.If you click cancel then it will be cancelled.


Using PROMPT method
<script language="JavaScript">
<!-- hide from older browser
var answer=prompt("please enter your name")
if(answer=="ncthakur"){
window.location="js04.htm"
}
//-->
</script>

In this example, an interactive dialogue box will be displayed with the message-please enter your name and unless you type ncthakur in the empty text area and click, you will not be taken to javascript page 4 of this web site because the answer to the prompt is equal to ncthakur. You can replace that answer in the code with your own.

BACK

NEXT..........

Top

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