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.

Thanks for the marvelous posting! I quite enjoyed reading
it, you are a great author. I will make certain to bookmark your blog and will often come back in the future.
I want to encourage yourself to continue your great writing, have a
nice holiday weekend!
Spider - 2 weeks
Hey I know this is off topic but I was wondering if you knew of
any widgets I could add to my blog that automatically tweet
my newest twitter updates. I've been looking for a plug-in like this for quite
some time and was hoping maybe you would
have some experience with something like this.
Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your
new updates.
Texas LLC - 1 months
I always emailed this blog post page to all my associates, because if like to read it next my links will too.
50 mg viagra - 2 months

Powered by Linode.