Windows Popup Alert


There are three different types of popup windows in JavaScript that can be used to display data or request input from the user: alert(), confirm(), and prompt().

alert()

The alert() method displays a message in a popup dialog box with an "OK" button. This can be useful for displaying information or notifying the user of an event.

Example

Preview

confirm()

The confirm() method displays a message in a popup dialog box with "OK" and "Cancel" buttons. This can be useful for prompting the user to confirm an action or make a decision. This method returns true if the user clicked "OK" and if the user clicked "Cancel".

Example

Preview

prompt()

The prompt() method displays a message in a popup dialog box with text input fields and "OK" and "Cancel" buttons. This can be useful for prompting the user for input such as a username or password. This method returns the text entered by the user if the user clicks "OK" and if the user clicks "Cancel".

Example

Preview

It should be noted that popup boxes should be used rarely and with caution as they can interfere with the user experience and can be seen as invasive or bothersome. It is often advisable to employ less obvious and intrusive methods of informing users of information or soliciting their feedback, including alerts or inline forms.