Chapter 4. Dialog Boxes

image

4.1 Interacting with the User

Programs like to talk, ask questions, get answers, and respond. In the previous chapter, we saw how the write() and writeln() methods are used to send the document’s output to the browser. The document is defined in an object and write() and writeln() are methods that manipulate the document, make it do something. The document object is defined within a window. The window is also an object and has its own methods.

The window object uses dialog boxes to interact with the user. The dialog boxes are created with three methods:

alert()

prompt()

confirm()

4.1.1 The alert() Method

The window’s ...

Get JavaScript by Example 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.