Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The window object includes three methods that are useful for displaying messages and interacting with the user. You’ve already used these in some of your scripts. Here’s a summary:
• window.alert(message) displays an alert dialog box. This dialog box simply gives the user a message.
• window.confirm(message) displays a confirmation dialog box. This displays a message and includes the OK and Cancel buttons. This method returns true if OK is clicked and false if Cancel is clicked.
• window.prompt(message,default) displays a message and prompts the user for input. It returns the text entered by the user. If the user does not enter anything, the default value is used.
Tip
You can usually omit the window object when referring to these methods because it is the default context of a script (for example, alert("text")).