Popup Boxes
Popup boxes in JavaScript are used display information to the user or request information from the user.
alert statement
The alert statement displays a popup box containing a text message with an "OK" button. It is used to display information to the user.
The alert
statement has the following syntax:
alert("text");
The following example shows the basic use of the alert
statement.
<html>
<body>
<script>
alert("Alert Message");
</script>
</body>
</html>
This produces the following result:

confirm statement
The alert statement displays a popup box containing a text message with an "OK" and "Cancel" buttons. It is used to display information and have the user verify or accept something.
The confirm
statement has the following syntax:
confirm("text");
The following example shows the basic use of the confirm
statement.
<html>
<body>
<script>
confirm("Ready for more?");
</script>
</body>
</html>
This produces the following result:

prompt statement
The prompt statement displays a popup box containing a text message, an input box, and "OK" and "Cancel" buttons. It is used to display a message and have the user input a value.
The prompt
statement has the following syntax:
prompt("text", "defaultvalue");
The following example shows the basic use of the prompt
statement.
<html>
<body>
<script>
prompt("Name:", "Fred");
</script>
</body>
</html>
This produces the following result:
