Javascript implements a simple example of child parent forms passing values to each other

  • 2020-03-30 01:45:27
  • OfStack

Window. showModalDialog()

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

Url  --   Required parameter, type: string that specifies the URL of the document to be displayed in the dialog box

Arguments  -- Optional parameters, type: variant, used to pass parameters to the dialog box, passed parameters of any type, including array, dialog box through window.dialogArguments to get passed in the parameters

Features    --   Optional parameter, type: string, used to describe the appearance of the dialog box, you can use one or more of the following, with the semicolon ";" separated

DialogHeight: dialogHeight, not less than 100px
DialogWidth: dialogWidth
DialogLeft: the distance to the left of the screen
DialogTop: the distance from the screen
Center: {yes | no | 1 | 0} : center, default yes, but you can still specify the height and width & cake;  
Help: {yes | no | 1 | 0} : whether to display the help button, default yes
Resizable: {yes | no | 1 | 0} [IE5+] : whether the size can be changed, default no
Status: {yes | no | 1 | 0} [IE5+] : whether to display status bar, default is yes[Modeless] or no[Modal]
Scroll: {yes | no | 1 | 0 | on | off} : whether to display scrollbar, default is yes

Parameter transfer:

1. To pass arguments to the dialog box, arguments are passed through arguments. The type is not limited.
The parent. HTM


<script>
 var obj = new Object();
 obj.name="justflyhigh.com";
 window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>

Modal. HTM

<script>
 var obj = window.dialogArguments;
 alert(" The parameters you passed are: " + obj.name)
</script>

2. Information can be returned to the window that opens the dialog box through window.returnValue.

The parent. HTM


<script>
 var result =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
 alert(result);
</script>

Modal. HTM

<script>
 window.returnValue="//www.jb51.net";
</script>


Related articles: