showModalDialog method (window)
3 | ||||
Creates a modal dialog and loads the specified document into it.
While the modal dialog is open, the opener window cannot get the input focus and the showModalDialog method does not return.
Modal dialogs are always displayed on top of their opener windows.
The user cannot switch to the opener window until the modal dialog is closed.
The showModalDialog method is supported in Firefox from version 3.
Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
Required. String that specifies the location of the document to display in the modal dialog. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Optional. Specifies an object with an arbitrary type or a primitive value to pass to the dialog. Use the dialogArguments property to get this value in the dialog. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Optional. String that specifies a comma-separated list of options. Each option is a name, value pair, delimited by a semicolon.
The following options are supported:
|
Return value:
Returns the value of the returnValue property of the dialog window.
Example HTML code 1:
This example creates a modal dialog and communicates between the opener and the modal window:
|
|||||
<head> <script type="text/javascript"> function UpdateFields (newFore, newSur) { var forename = document.getElementById ("forename"); var surname = document.getElementById ("surname"); forename.value = newFore; surname.value = newSur; } function ShowModal () { var forename = document.getElementById ("forename"); var surname = document.getElementById ("surname"); var sharedObject = {}; sharedObject.forename = forename.value; sharedObject.surname = surname.value; if (window.showModalDialog) { var retValue = showModalDialog ("modal.htm", sharedObject, "dialogWidth:200px; dialogHeight:200px; dialogLeft:300px;"); if (retValue) { UpdateFields (retValue.forename, retValue.surname); } } else { // for similar functionality in Opera, but it's not modal! var modal = window.open ("modal.htm", null, "width=200,height=200,left=300,modal=yes,alwaysRaised=yes", null); modal.dialogArguments = sharedObject; } } </script> </head> <body> Forename: <input type="text" id="forename" value="Alan"/><br/> Surname: <input type="text" id="surname" value="Smith"/> <br/><br/> <button onclick="ShowModal ()">Edit the fields with a modal dialog!</button> </body> |
|||||
|
|||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments
Chrome has showModalDialog() but doesn't opens window as a modal. Its a bug in chrome and still exists in v18+.