Alert Popup Box

JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box.

Alert Box

An alert box is often used if you want to make sure information comes through to the user.

When an alert box pops up, the user will have to click “OK” to proceed.

Syntax

alert(“sometext”);

The window object provides the alert method, which allows you to display a simple dialog box containing a text message followed by a single button the user can use to acknowledge the message and close the dialog box.

Creating alert dialog boxes is one of many features of the window object, which can also be used to create confirmation and prompting dialog boxes, as well as other capabilities. These include the following:
• Opening pages in new windows
• Determining window sizes
• Controlling scrolling of the document displayed in the window
• Scheduling the execution of functions

Example

<html>
<head>
<script type="text/javascript">
function show_alert()
{
alert("I am an alert box!");
}
</script>
</head>
<body>

<input type="button" onclick="show_alert()" value="Show alert box" />

</body>
</html>

OUTPUT: