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>