ShowModalDialog: modal window, a very special kind of window, when it opens, the activity of the parent window will stop, unless the current Mode child window is closed to manipulate the parent window. When doing web Ajax development, we should sometimes use it to implement the form filling , or do a similar online answer to the window. It is characterized by the very convenient and powerful parameters, can directly call the parent window variables and methods.
How to use:
Vreturnvalue = window.showModalDialog (sURL [, varguments] [, Sfeatures])
parameter Description:
surl--
Required parameter, type: String. The URL used to specify the document to display in the dialog box.
varguments--
Optional parameter, type: Variant. Used to pass parameters to the dialog box. The parameter types passed are not limited, including arrays, and so on. The dialog box is window.dialogarguments to get the parameters passed in.
sfeatures--
Optional parameter, type: String. Used to describe information such as the appearance of a dialog box, you can use one or more of the following, with a semicolon ";" Separated.
1.dialogHeight:
dialog height, not less than 100px,ie4 dialogheight and dialogwidth The default unit is EM, and IE5 is PX, in order to facilitate its see, in the Definition of modal dialog box, with PX to do units.
2.dialogWidth:
The width of the dialog box.
3.dialogLeft:
The distance from the left of the screen.
4.dialogTop:
The distance from the screen.
5.center: {yes | no | 1 | 0}:
The window is centered, the default yes, but the height and width can still be specified.
6.help: {yes | no | 1 | 0}:
Whether to display the Help button, default yes.
7.resizable: {yes | no | 1 | 0}
[ie5+]: Whether the size can be changed. Default No.
8.status: {yes | no | 1 | 0}
[ie5+]: Whether the status bar is displayed. Default is yes[Modeless] or no[modal].
9.scroll:{Yes | no | 1 | 0 | on | off}:
Indicates whether the dialog box displays scroll bars. The default is yes.
The following attributes are used in an HTA and are generally not used in general Web pages.
10.dialoghide:{Yes | no | 1 | 0 | on | off}:
Whether the dialog box is hidden when you print or print a preview. The default is No.
11.edge:{Sunken | raised}:
Indicates the border style of the dialog box. Default is raised.
12.unadorned:{Yes | no | 1 | 0 | on | off}:
The default is No.
For example:
Parent.html
Copy Code code as follows:
<script>
function SetName (res) {
Document.getelementbyidx_x ("name"). Value=res;
}
function Selecttp () {
Pass the SetName function of the parent window to the child window window.showModalDialog (' child.html ', SetName, ' Dialogwitdh:300px;dialogheight:300px;center: Yes; ');
}
</script>
<input type= "button" value= "Submit" onclick= "selecttp ()"/>
<input type= "text" id= "name" name= ' name '/>
Child.html
<script language= "JavaScript" >
<!--
function SetName () {
var win= "";
if (window.dialogarguments!=null)
{
child window Gets the SetName function of the parent window and operates the assignment
win=window.dialogarguments;
Win (' Jone ');
}
This.close ();
}
-->
</SCRIPT>
<input type= "button" value= "Assign value to parent window" onclick= "SetName ()"/>