The entire HTML page is modelled as a document object. Similarly the window in web browser is modelled as Window object. The window object include three methods to create dialog boxes for various kind of interaction with the users.
The alert() method is used to open a dialog box and display the text string provided as argument to alert() method. The alert dialog contains only “Ok” button. The text string is not an HTML but its plain text. The string may include newline (\n) character, but cannot include HTML tags.
window.alert(“This is the alert message”);
The confirm() method is used to open a dialog box and display the text string provided as an argument to confirm method and has two buttons: “Ok” and “Cancel”. This method returns boolean value indicating true for clicking “Ok” button and false value for clicking “Cancel” button.
The prompt() method is used to open a dialog box containing text box to collect input from the user and returns this value. This prompt dialog box also contains two buttons: “Ok” and “Cancel”. The prompt method takes two arguments: text string and default value. For example:
var avalue = prompt(“Input A”,””);