The Window Object

Dialog Boxes

The Window object provides three methods for displaying simple dialog boxes

  • alert() displays a message to the user and waits for the user to dismiss the dialog.
  • confirm() displays a message, waits for the user to click an OK or Cancel button
  • prompt() displays a message, waits for the user to enter a string, and returns that string.

This feature has been removed from the Web standards


In addition to the Window methods alert(), confirm(), and prompt(), a more complicated method, showModalDialog(), displays a modal dialog box containing HTML- formatted content and allows arguments to be passed to, and a value returned from, the dialog.

  1. The first argument is the URL that specifies the HTML content of the dialog box.
  2. The second argument is an arbitrary value (arrays and objects are allowed) that will be made available to scripts in the dialog as the value of the window.dialogArguments property.
  3. The third argument is a nonstandard list of semicolon-separated name=value pairs that, if supported, may configure the size or other attributes of the dialog.Use “dialogwidth” and “dialogheight” to set the size of the dialog window, and use “resizable=yes” to allow the user to resize the window.

     An HTML file for use with showModalDialog()
     showModalDialog("form.html",["Enter 3D point coordinates", "x", "y", "z"],
     "dialogwidth:400; dialogheight:300; resizable:yes");