- The variable declaration done by using the var statement.
- Eg#1
<script>
var x=window.confirm("Are you sure you want to quit")
if (x)
| window.alert("Thank you.") |
else
| window.alert("Good choice.") |
</script>
- Eg#2
<script>
var y=window.prompt("please enter your name")
window.alert(y)
</script>
- Eg#3
<html><head>
<script>
var x=confirm("Are you sure you want to quit?")
if (!x)
window.location="http://www.yahoo.com"
</script>
</head>
<body>
Welcome to my website!.
</body></html>
- From the above example, if you click "cancel", it will take you to yahoo, and clicking ok will continue with the loading of the current page "Welcome to my website!".
Note: | If (!x)means: if click "cancel". In JavaScript, the exclamation mark ! means: "none". |
0 comments :
Post a Comment