Javascript Reference
Categories: window

javascript window showModalDialog( )

@March 4, 2010, 3:15 a.m.
showModalDialog( ) It works on all browsers.

showModalDialog("URL"[, arguments[, "features"]])


Displays a special window that remains atop all browser windows until the user explicitly closes the dialog window. This kind of window is different from the browser windows generated with the ) method. A modal dialog has no scriptable relationship with its opening window once the dialog window is opened. All values necessary for displaying content must be in the HTML document that loads into the window or be passed as parameters. The modal dialog may then have a script set its returnValue property, which becomes the value returned to the original script statement that opened the modal dialog box as the returned value of the showModalDialog( ) method.

You can pass arguments to the modal dialog by creating a data structure that best suits the data. For a single value, a string will do. For multiple values, you can create a string with a unique delimiter between values, or create an array and specify the array as the second parameter for the showModalDialog( ) method. A script in the document loaded into the modal dialog can then examine the window.dialogArguments property and parse the arguments as needed for its scripting purposes. See the dialogArguments property for an example.

The third optional parameter lets you set physical characteristics of the dialog window. These characteristics are specified in a CSS-style syntax. Dimensions for dialogWidth, dialogHeight, dialogLeft, and dialogTop should be specified in pixels. An example of a call to a modal dialog is as follows:

var answer = window.showModalDialog("subDoc.html",argsVariable, 
"dialogWidth:300px; dialogHeight:200px; center:yes");

None of the third parameter characteristics are recognized by the Macintosh version of Internet Explorer 4, which creates a full-size modal dialog.

Modal dialogs can present problems for scripts if the window loads a frameset. A script in one of the frames will likely not be able to reference the parent or top window to gain access to either the window's close( ) method or content in another frame.

Feature Value Description
center yes | no | 1 | 0 | on | off Center the dialog
dialogHeight Length/units Outer height of dialog
dialogLeft Integer Left pixel offset (overrides center)
dialogTop Integer Top pixel offset (overrides center)
dialogWidth Length/units Outer width of dialog
edge raised | sunken Transition style between border and content area
help yes | no | 1 | 0 | on | off Display help icon in titlebar
resizable yes | no | 1 | 0 | on | off Dialog is resizable
status yes | no | 1 | 0 | on | off Display status bar
  • A complete or relative URL as a string.
  • Data as a number, string, or array to be passed to the scripts in the document loaded into the modal dialog.
  • A string of semicolon-delimited style attributes and values to set the physical characteristics of the modal dialog. Available attributes are as shown in the following table.
Returned Value

The value (if any) assigned to the window.returnValue property in the document loaded into the modal dialog window.

This is very interesting, You are a very skilled blogger.
I've joined your feed and look forward to seeking more
of your fantastic post. Also, I've shared your web site in my social networks!
gamefly free trial - 3 weeks
Hi there Dear, are you truly visiting this web site regularly, if so then you will definitely obtain fastidious experience.
how to get help in windows 10 - 3 weeks
Amazing! This blog looks just like my old one!
It's on a completely different topic but it has pretty much the same layout and design. Wonderful choice of colors!
gamefly free trial - 1 months

Powered by Linode.