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 |
| ||
if and else statement is used to make something happen in a given condition, else to happen something else in another condition. var is variable used to define an object. nct1 is a prompt, which asks if you like apple or javascript. nct2 is "You are wonderful". If your answer to nct1 is apple, it will write You are wonderful, you like to eat fruits;-; else in case of your answer as javascript, it will write You are intelligent, you can learn javascript easily <script language="JavaScript><--hide from older browser var nct1= prompt("Do you like apple or javascript?") var nct2="You are wonderful" var nct3="You are intelligent" if (nct1=="apple") { document.write(nct2+", you like to eat fruits!"); } else if (nct1=="javascript"){ document.write(nct3+", you can learn JavaScript easily"); } //--> </script> The use of two = sign in if (nct1= ="apple") is to tell the JavaScript that nct1 may or may not be equal to apple. It could be equal to javascript too as in (nct1= ="javascript"). Using only one = sign will tell the JavaScript that nct2 must be equal to "You are wonderful".
It is good to keep in mind that MSIE (Microsoft Internet Explorer) and NS (Netscape Navigator) browsers behave differently while interpreting JavaScript Codes, and it is always wise to use cross-browser codes that works well with both the browsers or to have two different web pages for different browsers.
|
Home
| About Me
| Nepal
| Articles
| Kavitaharu
| Cool Links
Javascript | Add Email | Guestbook |