Using the confirm() Method
The confirm() method works similarly to alert(), but this box is used to give the user a choice between OK and Cancel. You can make it appear in pretty much the same way, with the only difference being that instead of using the alert() method, you use the confirm() method.
So again, following the same routine as for the alert() method, you begin by adding the confirm() method to the script block as follows:
And again, the message you want to appear in the box is typed inside the parentheses, contained in quotes:
Save the file (again under a different name from the template and remembering to use the HTM or HTML file extension) and load it into the browser (see Figure 3.8).
Exercise - Practice adding the confirm() method to a Web page. Add your own messages.
Add a couple of separate confirm() methods to a Web page and note the result.