A simple example of using javascript to transmit values between child and parent forms

Source: Internet
Author: User

A simple example of using javascript to transmit values between child and parent forms

This article mainly introduces a simple example of how to implement the mutual passing of values in a child parent form in javascript. If you need it, you can refer to it for help.

Window. showModalDialog () usage:

 

Var returnValue = window. showModalDialog (url [, arguments] [, features]);

 

Url -- required parameter; Type: String, used to specify the URL of the document to be displayed in the dialog box

 

Arguments -- optional parameter, type: variant, used to pass parameters to the dialog box. The parameter types are not limited, including arrays. the dialog box uses window. dialogArguments to obtain the passed parameters.

 

Features -- 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 (;).

 

DialogHeight: the dialog box height, not smaller than 100px

DialogWidth: Dialog Box width

DialogLeft: distance from the left of the screen

DialogTop: distance from the screen

Center: {yes | no | 1 | 0}: whether to center. The default value is yes, but the height and width can still be specified.

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

Resizable: {yes | no | 1 | 0} [IE5 +]: whether the size can be changed. The default value is no.

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

Scroll: {yes | no | 1 | 0 | on | off}: whether to display the scroll bar. The default value is yes.

 

Parameter transfer:

 

1. If you want to pass parameters in the dialog box, you can use arguments to pass parameters. The type is unlimited. For string types, the maximum value is 4096 characters. You can also pass objects. For example:

Parent.htm

 

The Code is as follows:

<Script>

 

Var obj = new Object ();

 

Obj. name = "justflyhigh.com ";

 

Window. showModalDialog ("modal.htm", obj, "dialogWidth = 200px; dialogHeight = 100px ");

 

</Script>

 

 

Modal.htm

The Code is as follows:

<Script>

Var obj = window. dialogArguments;

Alert ("the parameter you passed is:" + obj. name)

</Script>

 

2. You can use window. returnValue to return information to the window that opens the dialog box. It can also be an object, for example:

 

Parent.htm

 

The Code is as follows:

<Script>

Var result = window. showModalDialog ("modal.htm", "dialogWidth = 200px; dialogHeight = 100px ");

Alert (result );

</Script>

 

Modal.htm

The Code is as follows:

<Script>

Window. returnValue = "http://www.jb51.net ";

</Script>

 

 

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.