window.confirm()

JavaScript1.0+, JScript1.0 Nav2+, IE3+, Opera3+ Syntax

							window.confirm(string)

Description

The confirm() method of the Window object displays a confirmation dialog box when invoked. The value of the string passed to the method is displayed in the box. This box will contain both an OK and Cancel button. The method returns a Boolean value of true if the user clicks OK and false if the user clicks Cancel.

Example

Listing 7.533 pops up a confirmation box when the script is loaded to see if the user wishes to proceed. Once the user makes a decision, the script writes his choice to the page. The result of running this script can be seen in Figure 7.17.

Figure 7.17. A confirmation box created with the Window.confirm() method. ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.