Details about js showModalDialog pop-up window instances

Source: Internet
Author: User

ShowModalDialog:Mode window, a very special window. When it is opened, the activity of the parent window will stop. The parent window can be operated only when the child window of the current mode is closed. during webpage Ajax development, we should sometimes use it to fill in forms or make windows similar to online Q &. it features convenient and powerful parameter passing, and can directly call the variables and methods of the parent window.

Usage:
VReturnValue = window. showModalDialog (sURL [, vArguments] [, sFeatures])

Parameter description:
SURL --
Required parameter. Type: string. Specifies the URL of the document to be displayed in the dialog box.

VArguments --
Optional parameter; Type: variant. Used to pass parameters to the dialog box. The passed parameter types are not limited, including arrays. The dialog box uses window. dialogArguments to obtain the passed parameters.

SFeatures --
Optional parameter; Type: String. Used to describe the appearance and other information of the dialog box. You can use one or more of the following, separated by semicolons.

1. dialogHeight:
The dialog box height. The default unit of dialogHeight and dialogWidth in IE4 is em, while that in IE5 is px. For convenience, When you define the modal mode dialog box, unit with px.

2. dialogWidth:
Dialog Box width.

3. dialogLeft:
The distance from the left of the screen.

4. dialogTop:
The distance from the screen.

5. center: {yes | no | 1 | 0 }:
Whether the window is centered. The default value is yes, but the height and width can still be specified.

6. help: {yes | no | 1 | 0 }:
Whether to display the Help button. The default value is yes.

7. resizable: {yes | no | 1 | 0}
[IE5 +]: whether the size can be changed. No by default.

8. status: {yes | no | 1 | 0}
[IE5 +]: whether to display the status bar. The default value is yes [Modeless] or no [Modal].

9. scroll: {yes | no | 1 | 0 | on | off }:
Specifies whether the scroll bar is displayed in the dialog box. The default value is yes.
The following attributes are used in HTA and are not used in general web pages.

10. dialogHide: {yes | no | 1 | 0 | on | off }:
Whether the dialog box is hidden during print or preview. The default value is no.

11. edge: {sunken | raised }:
Specify the border style of the dialog box. The default value is raised.

12. unadorned: {yes | no | 1 | 0 | on | off }:
The default value is no.

FOR example:
Parent.html
Copy codeThe Code is as follows:
<Script>
Function setname (res ){
Document. getElementByIdx_x ("name"). value = res;
}
Function selectTp (){
// Pass the setnamefield in the parent window to the 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)
{
// The Child Window obtains the setname function of the parent window and assigns a value to the operation.
Win = window. dialogArguments;
Win ('jone ');
}

This. close ();

}

// -->
</SCRIPT>
<Input type = "button" value = "assign a value to the parent window" onclick = "setName ()"/>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.