Open new window, window.open and window.showModalDialog

Source: Internet
Author: User

window.open:

Window.Open is a non-resistive window, also known as a modeless window, that is, when you open window.open this child window, you can also switch to manipulate the parent window.

The general format is this:


  1. <Spanstyle="FONT-SIZE:14PX;"><Strong>window.open (' page.html ', ' newwindow ', 'height=100,width=400, top=0, left=0,  toolbar=no, menubar=no, scrollbars=no, < span class= "attribute" >resizable=no, location=no, status=no ')     //the sentence as a line of code </strong> </span>  


Where parameters:

window.open the command that pops up the new window;
The filename of the ' page.html ' pop-up window;
The name of the ' NewWindow ' pop-up window (not the file name), not required, available empty ' ' instead;
height=100 window height;
width=400 window width;
The pixel value of the Top=0 window from the top of the screen;
The pixel value of the left=0 window from the left side of the screen;
Toolbar=no whether the toolbar is displayed, yes is displayed;
MenuBar, which indicates the menu bar

ScrollBars indicates scroll bar, yes indicates page allows scrolling
Resizable=no whether the window size is allowed to change, yes is allowed;
Location=no whether the address bar is displayed, yes is allowed;
Status=no whether the information in the status bar is displayed (usually the file is already open), yes is allowed;

window.showModalDialog:

window.showModalDialog indicates a blocking window, that is, when the window is opened, the parent window is not allowed to be manipulated until it is closed

The general format is this:


    1. <strong>window.showmodaldialog ("modal.htm", "", "dialogwidth=200px;  dialogheight=100px "); </Strong>

Some parameters:

Dialogheight: Height of dialog box, not less than 100px
Dialogwidth: The width of the dialog box.
Dialogleft: The distance from the left of the screen.
Dialogtop: Distance from the screen.
Center: {yes | no | 1 | 0}: Centered, default Yes, but can still specify height and width.
Help: {yes | no | 1 | 0}: Whether to display the Assist button, default yes.
Resizable: {yes | no | 1 | 0} [ie5+]: Whether the size can be changed. Default No.
Status: {yes | no | 1 | 0} [ie5+]: Whether the status bar is displayed. Default is yes[Modeless] or no[modal].
Scroll: {yes | no | 1 | 0 | on | off}: Scroll bar is displayed. The default is yes.

The following properties are used in an HTA and are generally not used in general Web pages.
dialoghide:{Yes | no | 1 | 0 | on | off}: Whether the dialog box is hidden when printing or printing preview. The default is No.
edge:{Sunken | raised}: Indicates the border style of the dialog box. The default is raised.
Unadorned: Default is No.

The general also to interact with the parent window, respectively, using Window.opener and window.dialogarguments, the specific use of the method can be on-line Baidu,

I'll add it when I get to know it.

(2017-3-17 18:37:27)

(add: For example, on a page using window.showModalDialog to open a page B and wear the value of the past, there can be a number of values including arrays, objects, etc., in the form of: (In JS on page a)


    1. var obj = new Object ();
    2. obj.name="51js";
    3. var jieshou = window.showmodaldialog ("modal.htm", obj, "dialogwidth=200px;   dialogheight=100px ");

, and then receive it on the B page to write:


    1. var obj = window.dialogarguments
    2. Alert ("You passed the parameter:" + obj.name)

This means that you receive a page upload value, how Yang Yong is your business,

Then you want to close the page and then pass a value to the a page, on the B page this write:


    1. window.returnvalue="Hello";

Thus, the variable of Jieshou defined in the A-page JS is the value returned on the B-page, thus realizing the form of interaction between a seed window and a parent window! )

What about the interaction between the parent and child windows of window.open?

For example, the parent window's argument is this, the general to be in the form of a string to pass, specific can not be transmitted to other forms, I have not to delve into.


    1. function openTable (ID) {
    2. var feathers="Status=no,width=650px,height=670px,top=0px,menubar=no,resizable=no,scrollbars=yes,toolbar    =no,channelmode=no ";
    3. var openwin = window.open ("allinfo.html?")    +id+ "," +new Date (). GetTime (), "declare", feathers);
    4. Openwin.focus ();
    5. }

The child window then uses Window.location.search to receive the question mark (? ), and then split the string to get the value you want.


  1. <span style="FONT-SIZE:24PX;" ><script type="Text/javascript">
  2. var params= window.location.search;//params:?id,date
  3. var arr = params.substring (1). Split (",");
  4. var id = Arr[0];
  5. </Script> </span>

This allows the Id,window.opener to be used as a child window to manipulate the parent window directly, for example, when a child window is closed, call Window.opener.location.reload () to refresh, or, for example, Manipulate the data of the parent window directly on the child window page, such as: Window.opener.document.getElementById ("name"). Value = "input data"; To use JS to value or assign values.

Open new window, window.open and window.showModalDialog

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.