Parameter passing in window.open() and window.showModalDialog

Reprint address: http://www.jb51.net/article/60507.htm

The example of this article describes the usage of window.showModalDialog and window.open of js. Share it with everyone for your reference. The specific analysis is as follows:

1. Window.open() supports environment:  JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+

2. Basic grammar:

1
window.open(pageURL,name,parameters)

 

in:

pageURL is the child window path 
name is the child window handle 
parameters is the window parameter (parameters are separated by commas)

3. Example:

1
2
3
4
5
6
<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' )
//写成一行
-->
</SCRIPT>

After the script runs, page.html will be opened in a new window newwindow, with a width of 100, a 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, no status bar.
Please check.

The above example involves several commonly used parameters, in addition to many other parameters, please refer to the parameter descriptions described below.


4. Various parameters

Among them, yes/no can also use 1/0; pixel value is a specific value, and the unit is pixel.

parameter Ranges illustrate
alwaysLowered yes/no Specifies that the window is hidden behind all windows
alwaysRaised yes/no The specified window is suspended on top of all windows
depended yes/no Whether to close the parent window at the same time
directories yes/no Whether the directory bar of Nav2 and 3 is visible
height pixel value window height
hotkeys yes/no Set safe exit hotkey in windows without menu bar
innerHeight pixel value The pixel height of the document in the window
innerWidth pixel value The pixel width of the document in the window
location yes/no Whether the location bar is visible
menubar yes/no Whether the menu bar is visible
outerHeight pixel value Sets the pixel height of the window (including decorative borders)
outerWidth pixel value Sets the width in pixels of the window (including decorative borders)
resizable yes/no Whether the window size can be adjusted
screenX pixel value The length in pixels of the window from the left edge of the screen
screensY pixel value The length in pixels of the window from the top border of the screen
scrollbars yes/no Whether the window can have a scroll bar
titlebar yes/no Whether the window title bar is visible
toolbar yes/no Whether the window toolbar is visible
Width pixel value the pixel width of the window
z-look yes/no Whether the window floats on top of other windows when activated

window.showModalDialog manual

basic introduction:

showModalDialog() (IE 4+ support)
showModelessDialog() (IE 5+ support)
The window.showModalDialog() method is used to create a modal dialog that displays HTML content.
The window.showModelessDialog() method is used to create a modeless dialog that displays HTML content.

Instructions:

 
1
2
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 by the dialog.
vArguments --
optional arguments, type: variant. Used to pass parameters to the dialog. The types of parameters passed are not limited, including arrays, etc. The dialog gets the parameters passed in through window.dialogArguments.
sFeatures--
optional parameter, 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 a semicolon ";".

1.dialogHeight : 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.
2.dialogWidth: Dialog 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 it can be resized. Default no.
8.status: {yes | no | 1 | 0 } [IE5+]: Whether to display the status bar. Defaults to 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 is hidden during printing or print preview. Defaults to no.
11.edge:{ sunken | raised }: Specifies the border style of the dialog box. Defaults to raised.
12.unadorned:{ yes | no | 1 | 0 | on | off }: The default is no.

Parameter passing:

1. To pass parameters to the dialog box, it is passed through vArguments. The type is not limited, for string type, the maximum is 4096 characters. Objects can also be passed, for example:

parent.htm:

1
2
3
4
5
<script>
var obj = new Object();
obj.name= "51js" ;
window.showModalDialog( "modal.htm" ,obj, "dialogWidth=200px;dialogHeight=100px" );
</script>

modal.htm:

1
2
3
4
<script>
var obj = window.dialogArguments
alert( "您传递的参数为:" + obj.name)
</script>

You can also directly obtain the element value in the parent window through window.dialogArguments in modal.htm, such as:

 var sCheckID = window.dialogArguments.document.all("Element name value in parent window").value;

2. You can return information to the window that opened the dialog box through window.returnValue, of course, it can also be an object. E.g:

parent.htm

1
2
3
4
<script>
str =window.showModalDialog( "modal.htm" ,, "dialogWidth=200px;dialogHeight=100px" );
alert(str);
</script>

modal.htm

1
2
3
<script>
window.returnValue= "http://www.jb51.net" ;
</script>

Currency Definition Section

1
2
3
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;" );

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325008538&siteId=291194637
Recommended