Creating Popup Windows
Window objects provides several different methods that allow you to launch popup windows that you can interact with for alerts, prompts, and notifications. The popup windows are displayed, and the user needs to interact with the popup before continuing to access the web page.
There are three kinds of popup boxes that can be created:
- alert(msg)—Launches a popup window that displays an alert message and provides a button to close the popup.
- confirm(msg)—Launches a popup window that displays a confirmation and message provides an OK and a Cancel button, which both close the popup. If you click the OK button, the return value from confirm() is true; otherwise, it is false.
- prompt(msg)—Launches a popup window that displays the message, a text box for input, and an OK and Cancel button, which both close the popup. If you click the OK button, the return value from prompt() is the text typed into the text box; otherwise, it is false.
The code that follows illustrates these popup boxes, as shown in Figure 3.1.