WINDOW POP UPS
- Alert Box
- Prompt Box
- Confirm Box
Pop Up Windows
The way these three popup windows look is determined by different kinds of browser. These boxes can't be modified by CSS.
Lets see all three types of popups and their use.
The alert box displays small messages. It contains one OK button.
To create an alert box use
The following example shows how to display messages using an alert box.
The confirm box is used to interact with users. It takes input from the user in form of confirmation, whether a task should be performed or not.
The confirm box is created by
window.confirm() method. It is a global method so it can be used without referring to the
The confirm box is similar an alert box but it can return
boolean value, which is used to know what was the action taken by the user for the confirmation.
The confirm box contains two buttons, one is the OK button which returns
true other is cancel button which returns
false. It also displays a message which is passed in the
confirm() method as an argument.
The prompt box is created using
window.prompt() method. Since it is a global method so it is accessible everywhere and can be used without referring to the
The prompt box contains an OK button which returns input value in the form of string.
The following example will take two inputs from the user and will print their sum.