JavaScript Pop Up Boxes
JavaScript has three kind of pop-up boxes,
i) Alert-Box: If some surety is required from the user or an alert message is to generate then we can use alert box, user has to click ok button to proceed.
ii) Confirm Box: This box is used when some confirmation is required from user, it has ok and cancel button. Ok button returns true value and Cancel button returns false value.
iii) Prompt Box: This box is used when the web page needs some input from user, it has ok and cancel button. Ok button returns the value entered by the user and cancel button returns null value.
Example 1 (Alert Box):
<html>
<head>
<script type="text/javascript">
alert("This is an alert box");
</script>
</head>
</html>
Output:

Example 2 (Confirm Box):
<html>
<head>
<script type="text/javascript">
var a=confirm("This is a cofirm box");
if(a==true)
{
document.write("You have clicked ok");
}
else
{
document.write("You have clicked cancel");
}
</script>
</head>
</html>
Output:

If you click OK button:
You have clicked ok
If you click cancel button:
You have clicked cancel
Example 3 (Prompt Box)
<html>
<head>
<script type="text/javascript">
var a=prompt("Enter your age"," ");
if(a>=18)
{
document.write("Eligible to cast your vote");
}
else
{
document.write("Sorry you are not Eligible");
}
</script>
</head>
</html>
Output:

if you enter equal or more than 18 output will be displayed on the browser as follows:
Eligible to cast your vote
Otherwise:
Sorry you are not Eligible
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.