The difference between ShowModalDialog and window.open

Source: Internet
Author: User
ShowModalDialog function, changing modal window size

functions of the ShowModalDialog function:
Opens a child window and can pass data to and from the parent window, and the biggest difference to window.open is that when a child window is opened by ShowModalDialog, the parent window cannot operate.
How to use:
Vreturnvalue = window.showModalDialog (sURL [, varguments] [, Sfeatures])
parameter Description:
sURL
Required parameter, type: String. The URL used to specify the document to display in the dialog box.
Varguments
Optional parameter, type: Variant. Used to pass parameters to the dialog box. The parameter types passed are not limited, including arrays, and so on. The dialog box is window.dialogarguments to get the parameters passed in.
Sfeatures
Optional parameter, type: String. Used to describe information such as the appearance of a dialog box, you can use one or more of the following, with a semicolon ";" Separated.
Dialogheight dialog box height, not less than 100px,ie4 dialogheight and dialogwidth The default unit is EM, and the IE5 is PX, for the convenience of its see, in the Definition of modal dialog box, with PX to do units.
Dialogwidth: Dialog box width.
Dialogleft: The distance from the left of the desktop.
Dialogtop: The distance from the desktop.
Center: {yes | no | 1 | 0}: The window is centered, the default yes, but the height and width can still be specified.
Help: {yes | no | 1 | 0}: Do you want to show the assistance button, default yes.
Resizable: {yes | no | 1 | 0} [ie5+]: can be changed size. Default No.
Status: {yes | no | 1 | 0} [ie5+]: Whether the status bar is displayed. The default is yes[Modeless] or no [Modal].
scroll:{Yes | no | 1 | 0 | on | off}: Indicates whether the dialog box displays scroll bars. The default is yes.
Parameter Pass method:
The parent window passes the argument to the child window with the 2nd argument of ShowModalDialog, and the parent window gets the argument that the child window returns by using the return value of the ShowModalDialog function.
A child window gets the parent window parameter by using the child Window object Dialogarguments property, for example:
var a=window.dialogarguments;
The child window returns parameters to the parent window using the Window.returnvalue property, such as:
window.returnvalue=1;
Window.close ();

Change modal window size

1.html

<HTML>
<HEAD>
<TITLE> change the size of the dialog box </TITLE>
</HEAD>
<script>
function ShowDialog () {
window.showModalDialog ("2.html", "", ' edge:raised; center:yes; help:yes; resizable:yes; status:no;dialogheight:200px ;d ialogwidth:300px ');
}
</script>
<BODY>
<input Type=button value= "ShowDialog" onclick= "ShowDialog" (); " >
</BODY>
</HTML>

2.
<HEAD>
<TITLE> change the size of the dialog box </TITLE>
</HEAD>

<body onload=resize_dialog (1000,1000,1000,1000) >
<script language= "JavaScript" >
function Resize_dialog (t,l,w,h) {

Window.dialogtop = t+ "px";
Window.dialogleft = l+ "px";
Window.dialogheight = h+ "px";
Window.dialogwidth = w+ "px";
}

</SCRIPT>
</BODY>
</HTML>

=================================================================================

Window.Open is to open a new window

window.showModalDialog (Url,dialogargments.features) opens a new window
The URL is the page you want to open.
Dialogargments for parameters that are passed to the new window page, it can be any data type.
Feature is similar to open () and is a format setting. Call format is featurename1:featurevalue1: (semicolon) Featurename2:featurevalue2:
Certer, Dialogheight, dialogleft,dialogtop,dialogwidth,help (whether Show Help button, same below), status,resizeable
The value =1 is yes,0 to No.

I think the most important thing is dialogargments, which can pass the value to the new window.
The second important thing is that it returns a value of Window.returnvalue. You can return a value of any type before the ShowModalDialog open window closes

 
==================================================================================== ShowModalDialog () pops up a dialog box that is attached to the window on which it is opened; window.open () is a new window, and the window that opens it is separate

ShowModalDialog () You must close to operate the window that opens it, and the window.open () open window does not have to be closed or you can manipulate the window that opens it

The window method that controls the opening of it is also different, one uses dialogarguments, the latter uses opener

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.