Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 20. Using Windows and Frames > Displaying Dialog Boxes

Displaying Dialog Boxes

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")).


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial