This article describes the usage of window.showModalDialog and window.open of js. Share it for your reference. The specific analysis is as follows:
1. window.open() supports environment: JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+
2. Basic syntax:
window.open(pageURL, name, parameters)
in:
pageURL is the child window path
name is the child window handle
parameters are window parameters (each parameters are separated by commas)
3. Example:
<SCRIPT> <!-- window.open ('page.html','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no') //Write as one line--> </SCRIPT>After the script is run, page.html will be opened in the new form newwindow, with width of 100, height of 400, 0 pixels from the top of the screen, 0 pixels from the left of the screen, no toolbar, no menu bar, no scroll bar, no resize, no address bar, and no status bar.
Please compare.
The above examples are several commonly used parameters, and there are many other parameters in addition to this. You can refer to the parameter description described below.
4. Various parameters
Among them, yes/no can also be used 1/0; pixel value is the specific value, unit pixel.
| parameter | Value range | illustrate |
| AlwaysLowered | yes/no | Specify windows are hidden behind all windows |
| AlwaysRaised | yes/no | Specify the window to hang on all windows |
| Depended depending | yes/no | Whether to close the parent window at the same time |
| Directories | yes/no | Is the directory columns of Nav2 and 3 visible? |
| height | pixel value | Window height |
| hotkeys | yes/no | Set a safe exit hotkey in a window without a menu bar |
| innerHeight | pixel value | Pixel height of the document in the window |
| innerWidth | pixel value | Pixel width of the document in the window |
| location | yes/no | Is the location bar visible? |
| menubar | yes/no | Is the menu bar visible? |
| outerHeight | pixel value | Set the pixel height of the window (including decorative borders) |
| outerWidth | pixel value | Set the pixel width of the window (including decorative borders) |
| Resizable | yes/no | Is the window size adjustable? |
| screenX | pixel value | The pixel length of the window to the left border of the screen |
| screenY | pixel value | The pixel length of the window to the upper boundary of the screen |
| scrollbars | yes/no | Is there a scrolling bar available in the window |
| titlebar | yes/no | Is the window title column visible? |
| toolbar | yes/no | Is the window toolbar visible? |
| Width | pixel value | The pixel width of the window |
| z-look | yes/no | Does the window float on other windows after it is activated |
window.showModalDialog User Manual
Basic introduction:
showModalDialog() (IE 4+ support)
showModelessDialog() (IE 5+ support)
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.
How to use:
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 parameter, type: variant. Used to pass parameters to the dialog box. The passed parameter types are not limited, including arrays, etc. The dialog box uses window.dialogArguments to obtain the passed parameters.
sFeatures--
Optional parameter, type: string. Information used to describe the appearance of a dialog box, such as the following information, can be separated by a semicolon ";".
1.dialogHeight: The height of the dialog box is not less than 100px. The default units of dialogHeight and dialogWidth in IE4 are em, and px in IE5 are px. For the sake of convenience, when defining the dialog box in the modal method, px is used as the unit.
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 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 is yes.
7.resizable: {yes | no | 1 | 0 } [IE5+]: Whether the size can be changed. Default no.
8.status: {yes | no | 1 | 0 } [IE5+]: Whether to display the status bar. Default is yes[Modeless] or no[Modal].
9.scroll:{ yes | no | 1 | 0 | on | off }: Indicates whether the dialog box displays scroll bars. Default is yes.
The following attributes are used in HTA and are generally not used in general web pages.
10.dialogHide:{ yes | no | 1 | 0 | on | off }: Whether the dialog box is hidden when printing or printing preview. Default is no.
11.edge:{ sunken | raised }: Specify the border style of the dialog box. The default is raised.
12.unadorned:{ yes | no | 1 | 0 | on | off }: Default is no.
Parameter passing:
1. If you want to pass parameters in the dialog box, it is passed through vArguments. There is no restriction on type, for string types, the maximum is 4096 characters. Objects can also be passed, for example:
parent.htm:
<script>var obj = new Object();obj.name="51js";window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");</script>modal.htm:
<script>var obj = window.dialogArgumentsalet("The parameter you pass is: " + obj.name)</script>2. You can return information to the window where the dialog box is opened through window.returnValue, and of course it can also be an object. For example:
parent.htm
<script>str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");alert(str);</script>modal.htm
<script>window.returnValue="//www.VeVB.COM";</script>
Currency definition part
var psAddStr="ProcessID="+ProcessID+"&AddFlag="+isAddFlag+"&BZBH="+vsBZBH+"&BZMC="+vsBZMC+"&BZFH="+vsBZFH+"&JD="+vsJD; var Result=window.showModalDialog("addSave.asp?"+psAddStr,'',"dialogHeight:250px;dialogWidth:250px;status:no;");I hope this article will be helpful to everyone's JavaScript programming.