In the previous article, how to use Javascript to pass values between two forms explains how to use the window. open () method to open a new form and transfer values between two forms. Code for passing values between two Javascript forms
In javascript, there is also a function window. showModalDialog which can also open a new form. However, it opens a modal window. How can we pass a value between the parent form and the child form? Let's first look at the definition of this function: 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.
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 defining the modal mode dialog box, unit with px.
DialogWidth: Dialog Box width.
DialogLeft: the distance from the left of the screen.
DialogTop: the distance from the screen.
Center: {yes | no | 1 | 0}: whether the window is centered. 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. No by default.
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}: Specifies whether the scroll bar is displayed in the dialog box. The default value is yes.
For example, "dialogWidth = 200px; dialogHeight = 100px"
Therefore, we can pass values between two forms using the window. dialogArguments parameter.
For example, the following two pages: FatherPage.htm:
The Code is as follows: