jquery parent window communicates with child windows

Source: Internet
Author: User
Tags object window

$ ("#父窗口元素ID", window.parent.document);
Corresponding JavaScript version is window.parent.document.getElementByIdx_x ("Parent window Element ID");
Takes the element method of the parent window: $ (selector, window.parent.document);
Then you can take the element of the parent window of the parent window to use: $ (selector, window.parent.parent.document);
Similarly, there are similar methods for taking other windows.
$ (Selector, window. Top. Document);
$ (Selector, window. opener. Document);
$ (Selector, window. Top. Frames [0].document);
--------------------------------------------------------------------------------------------------
child window creation and communication between parent window and child window:

1, JavaScript pop-up child window
Can be implemented in a variety of ways, here are a few ways
(1) by using the open () method of the Window object, the open () method will produce a new Window object
Its usage is:
window.open (url,windowname,parameters);
URL: Describes the URL of the window to open, and how to empty it without opening any web page;
Windowname: Description of the opened window of the people said, you can use ' _top ', ' _blank ' and other built-in names, where the name and <a href= "..." target= "..." the target attribute in > is the same.
Parameters: Describes the parameter values of the window being opened, or the appearance, which includes the values of each property of the window, and the parameter values to pass in.
For example:
Open a clean window of x 100:
Open (', ' _blank ', ' width=400,height=100,menubar=no,toolbar=no,
Location=no,directories=no,status=no,scrollbars=yes,resizable=yes ')
You can also write this: var newwindow = open (', ' _blank ');
The parameter description is as follows:
The number of pixels off the top of the screen at the top of the top=# window
left=# window left the number of pixels leaving the left side of the screen
Width of the width=# window
Height of the height=# window
Menubar= ... Window has no menu, value Yes or no
Toolbar= ... Window has toolbar, value Yes or no
Location= ... window has no address bar, value yes or no
Directories= ... window has no connection area, value Yes or no
Scrollbars= ... Window has scroll bar, value Yes or no
Status= ... Window has status bar, value Yes or no
Resizable= ... window is not resized, value yes or no
(2) in JavaScript, in addition to the open () method to create a Window object implementation pop-up, you can create a dialog box pop-up window.
Such as:
Alert (""); Pop-up Message prompt dialog box
Confirm (""); Pop-up Message Confirmation dialog box
Prompt (""); dialog box with an interactive nature
However, the above implementation of the pop-up window has a single function, can only complete a relatively simple function. For the need to display multiple data information in a dialog box,
Even HTML controls are powerless.
(3) using modal dialogs to implement complex dialog box requirements
There is also a way in which JavaScript's built-in methods can be used to display HTML content through a dialog box,
That is, you can do what you can to create a window object by creating a dialog box.
This includes creating modal dialog boxes and modeless dialog boxes.
The implementation method is:
Create modal you dialog box
window.showModalDialog (Surl,varguments,sfeatures)
To create a modeless dialog box
Window.showmodelessdialog (Surl,varguments,sfeatures)
The difference is:
When you open a window with showModelessDialog (), you do not have to use Window.close () to turn it off, open the dialog box when it is not modal [IE5]
Window can still do other things, that is, the dialog box is not always the top focus, and when the URL of the window to open it changes, it automatically closes. The modal [IE4] mode dialog box always has the focus (the focus cannot be moved until it closes). The modal dialog box is associated with the window that opens it, so when we open another window, their link relationship is still saved and hidden underneath the active window. Showmodedialog () is not.

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.