Javascript has many built-in methods to generate dialog boxes, such as: window.alert(), window.confirm(), window.prompt(), etc. However, IE provides more methods to support dialog boxes. Such as:
showModalDialog() (IE 4 supported)
showModelessDialog() (IE 5 supported)
The window.showModalDialog() method is used to create a modal dialog box that displays HTML content. It is a dialog box, so it does not have all the properties of a window generally opened with window.open().
The window.showModelessDialog() method is used to create a non-modal dialog box that displays HTML content.
When we use showModelessDialog() to open a window, we don’t have to use window.close() to close it. When it is opened in non-modal mode [IE5], the window that opens the dialog box can still perform other operations. , that is, the dialog box is not always the top focus, and it automatically closes when the URL of the window that opens it changes. The modal [IE4] dialog box always has focus (the focus cannot be removed until it is closed). The modal dialog box is linked to the window that opened it, so when we open another window, their link relationship is still preserved and hidden under the active window.
The usage method is as follows:
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [, sFeatures])
Parameter description:
sURL
Required parameter, type: string. Used to specify the URL of the document to be displayed in the dialog box.
vArguments
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 obtains the parameters passed in through window.dialogArguments.
sFeatures
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 is the height of the dialog box, not less than 100px. The default unit of dialogHeight and dialogWidth in IE4 is em, while in IE5 it is px. For convenience, when defining a modal dialog box, use px as the unit.
DialogWidth: Dialog width.
dialogLeft: distance from the left side of the desktop.
dialogTop: distance from the desktop.
center: {yes | no | 1 | 0}: Whether the window is centered, 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 it can be resized. The default is no.
status: {yes | no | 1 | 0} [IE5]: Whether to display the status bar. The default is yes[Modeless] or no[Modal].
scroll:{ yes | no | 1 | 0 | on | off }: Indicate whether the dialog box displays scroll bars. The default is yes.
There are also several attributes used in HTA, which are generally not used in ordinary web pages.
dialogHide:{ yes | no | 1 | 0 | on | off }: Whether the dialog box is hidden during printing or print preview. The default is no.
edge:{ sunken | raised }: Specifies the border style of the dialog box. The default is raised.
unadorned:{ yes | no | 1 | 0 | on | off }: The default is no.
Incoming parameters:
To pass parameters to the dialog box, they are passed through vArguments. There is no limit on the type. For string types, the maximum length is 4096 characters. Objects can also be passed, for example:
test1.htm
test2.htm
test3.htm
Yes Return information to the window that opened the dialog box through window.returnValue, which of course can also be an object. For example:
test4.htm