The difference between window.open and ShowModalDialog in JS __js

Source: Internet
Author: User

Reprint Address: http://www.jb51.net/article/32590.htm


Open a new window in JS has been using open (), ShowModalDialog () has been almost forgotten, showmodaldialog and open as well as 3 parameters, ShowModalDialog (file Address, window, Windows properties), Open (file Address, Windows, window properties).

1. Open new Window title bar can see the minimized maximize button, and ShowModalDialog default is not, only a small fork

2. Open new window can click the mouse can be clicked on the parent window, ShowModalDialog only the new open window turned off the focus of the mouse can touch the parent window (in a way it is a dialog box).

3. The parameters of the ShowModalDialog window properties are different from the open window properties.

A. Open window height writing is not written here because it's the same as the HTML code attribute, look at the ShowModalDialog

B. Open (' http://hi.baidu.com/yp2010 ', ' window ', ' width=100,height=100,.. ')
var v=showmodaldialog (' http://hi.baidu.com/yp2010 ', window, "Dialogwidth:800px;dialogheight:600px;center:yes;edge : Raised; scroll:yes;status:no; ")

From the above code you can see that ShowModalDialog has a return value.
Dialogwidth: Wide, dialogheight: High, Center: Window position, Edge: Border style, scroll bar, status bar minimize:yes;maximize:yes, minimize maximize button ...

4. Window.dialogarguments method to invoke the parent window
5. Window.returnvalue returns the parameters of the parent window

To open a window similar to a dialog box, you can use the ShowModalDialog method.
Note: There is no special request to use open, with showmodaldialog words may encounter some problems.

6. In the modal window, form submission will pop up a new window, this problem is simple in

Note: I just started is not want to submit through form, with JS Window.location.href jump to different action to deal with, found
<base target= "_self" > does not work, it seems that <base target= "_self" > Just for the form action= "" To work, this place should be able to use IFRAME to achieve.

7. In page a call window.open open the window, the code will continue to execute downward, and ShowModalDialog will wait until the open new window is closed to continue to execute

For example: There is this code on page A:

Openwin (URL, "Viewnotice", null,800,600);
Openmodaldialog (URL, "Viewnotice", null,800,600);
alert (1111);

If you use open, the following code alert (1111) is executed after the new window is opened, and ShowModalDialog waits until the open new window closes to execute alert (1111);



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.