How to Create a Dialog with JavaScript
Read this JavaScript tutorial and learn information about the method which can create a modal dialog with an optional message and “OK” and “Cancel” buttons.
In the scope of this tutorial, we are going to show how you can create a modal dialog with an optional message and “OK” and “Cancel” buttons.
The <kbd class="highlighted">confirm()</kbd> JavaScript method will help you to create a dialog. It displays a prompt and returns true or false based on what the user chooses:
Javascript confirm method
The confirm() method
The <kbd class="highlighted">Window.confirm()</kbd> method displays a modal dialog with an optional message and “OK” and “Cancel” buttons. The message is an optional string that is displayed in the dialog, and the result is a boolean, which indicates whether OK (true) or Cancel (false) was selected. If a browser is ignoring in-page dialogs, then the result is always false.