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 window.open( ) 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.

Parameters
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.

Hi! I'm at work browsing your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Keep up the excellent work!|
This text is worth everyone's attention. Where can I find out more?|
Hello it's me, I am also visiting this web site regularly, this web site is actually good and the visitors are in fact sharing fastidious thoughts.|
I just could not depart your site before suggesting that I actually enjoyed the usual information an individual supply in your visitors? Is gonna be again steadily in order to check up on new posts|
This piece of writing presents clear idea in support of the new people of blogging, that really how to do running a blog.|
Ronaldcic - 1 months
You have made some good points there. I checked on the net for more info about the issue and found most individuals will go along with your views on this web site.|
Actually when someone doesn't be aware of afterward its up to other visitors that they will help, so here it takes place.|
What's up Dear, are you actually visiting this web site on a regular basis, if so afterward you will absolutely get pleasant knowledge.|
My partner and I stumbled over here different web page and thought I might as well check things out. I like what I see so i am just following you. Look forward to exploring your web page for a second time.|
Hello, I enjoy reading all of your post. I like to write a little comment to support you.|
Ronaldcic - 1 months
showModalDialog does not work in Google Chrome
Prem - 9 months

Powered by Linode.