The usage of window. showModalDialog () in JavaScript is described in detail.
Today, the pop-up subwindow is used in the project, and we think of two methods implemented using JavaScript. One is window. open (); one is window. showModalDialog () method. The latter is a pop-up window with a parent-child relationship. The parent window is activated only when the child window is closed and parameters and return values can be transmitted. I just reviewed the usage again. By the way, I recorded the problems encountered during the process.
Basic Introduction:
ShowModalDialog () (IE 4 + supported)
ShowModelessDialog () (IE 5 + supported)
The window. showModalDialog () method is used to create a modal dialog box that displays HTML content.
The window. showModelessDialog () method is used to create a non-modal dialog box that displays HTML content.
Usage:
VReturnValue = window. showModalDialog (sURL [, vArguments] [, sFeatures], "");
VReturnValue = window. showModelessDialog (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.
1. 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.
2. dialogWidth: Dialog Box width.
3. dialogLeft: the distance from the left of the screen.
4. dialogTop: the distance from the screen.
5. center: {yes | no | 1 | 0}: whether the window is centered. The default value is yes, but the height and width can still be specified.
6. help: {yes | no | 1 | 0}: whether to display the help button. The default value is yes.
7. resizable: {yes | no | 1 | 0} [IE5 +]: whether the size can be changed. No by default.
8. status: {yes | no | 1 | 0} [IE5 +]: whether to display the status bar. The default value is yes [Modeless] or no [Modal].
9. scroll: {yes | no | 1 | 0 | on | off}: Specifies whether the scroll bar is displayed in the dialog box. The default value is yes.
The following attributes are used in HTA and are not used in general web pages.
10. dialogHide: {yes | no | 1 | 0 | on | off}: whether the dialog box is hidden when printing or previewing. The default value is no.
11. edge: {sunken | raised}: Specify the border style of the dialog box. The default value is raised.
12. unadorned: {yes | no | 1 | 0 | on | off}: no by default.
Parameter transfer:
1. vArguments is used to pass Parameters in the dialog box. There is no limit on the type. For the string type, the maximum value is 4096 characters. You can also pass the object.
2. You can use window. returnValue to return information to the window that opens the dialog box. It can also be an object.