Home >Web Front-end >JS Tutorial >JavaScript implements a simple example of transferring values ​​between parent and child forms_javascript skills

JavaScript implements a simple example of transferring values ​​between parent and child forms_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:59:481160browse

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 parameters, type: variant, used to pass parameters to the dialog box. The type of parameters passed is not limited, including arrays, etc. The dialog box is passed in through window.dialogArguments Parameters

features -- Optional parameters, type: string, used to describe the appearance of the dialog box and other information. You can use one or more of the following, separated by semicolons ";"

dialogHeight: dialog box height, not less than 100px
dialogWidth: dialog box width
dialogLeft: distance from the left side of the screen
dialogTop: distance from the screen
center: { yes | no | 1 | 0 }: Whether to center, the default is yes, but the height and width can still be specified
help: {yes | no | 1 | 0}: Whether to display the help button, the default is yes
resizable: {yes | no | 1 | 0 } [IE5]: Whether the size can be changed, the default is no
status: {yes | no | 1 | 0} [IE5]: Whether the status bar is displayed, the default is yes[Modal] or no[Modal]
scroll: { yes | no | 1 | 0 | on | off }: Whether to display scroll bars, the default is yes

Parameter passing:

1. To pass parameters to the dialog box, they are passed through arguments. The type is not limited. For string types, the maximum length is 4096 characters. Objects can also be passed, for example:
parent.htm

Copy code The code is as follows:

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


modal.htm
Copy code The code is as follows:

<script><br> var obj = window.dialogArguments;<br> alert("The parameter you passed is: " obj.name)<br></script>

2. You can use window.returnValue to return information to the window where the dialog box is opened. Of course, it can also be an object, for example:

parent.htm

Copy code The code is as follows:

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

modal.htm
Copy code The code is as follows:

<script><br> window .returnValue="http://www.jb51.net";<br></script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn