Parent object in Javascript

Source: Internet
Author: User

This change always refers to the browser window at the highest level of the split window. If you plan to execute the command from the highest level of the split window, you can use the top variable.

Parent:

This variable refers to the parent window that contains the current split window. If there is a split window in a window, and one of the split Windows contains a split window, the split window at the layer 2nd can be referenced with the parent variable to include its parent split window.

Opener:

Refers to the original window corresponding to a new window created using window. Open and other methods.

 

Appendix: class relationships between window object, parent object, frame object, Document Object and form object: windwo object → parent object → frame object → Document Object → form object,

As follows: parent.frame1.doc ument. Forms [0]. elements [0]. value;

 

 

Problem: embed the framework <IFRAME> in a page, and then use the jvascript Script: parent. XX. value = 'xxxxx'; values can be normally displayed in IE, but cannot be assigned in Firefox. Which of the following is the object that calls the parent framework in Firefox? is it compatible with IE?

Answer: Invalid parameter parent.doc ument. form name. XX. value = 'xxxxx'; window can be omitted.

Parent.doc ument. form name. XX. value = 'xxxxx'; parent.doc ument. getelementbyid ("XX"). value = 'xxxxx ';

 

 

Differences between window. Parent and window. Opener JavaScript calls the Main Window Method

1: window. parent is the parent page object called by the IFRAME page

Example: a.html

<HTML>

<Head> <title> parent page </title>

<Body>

<Form name = "form1" id = "form1">

<Input type = "text" name = "username" id = "username"/>

</Form>

<IFRAME src = "B .html" width = 100%> </iframe>

</Body>

</Html>

Write in tables:

<SCRIPT type = "text/JavaScript">

VaR _ parentwin = Window. parent;

_ Parentwin. form1.username. value = "XXXX ";

</SCRIPT>

2: window. opener is a child page opened by window. Open. It calls the parent page object.

Opener: refers to the window object that opens the current window. If the current window is opened by the user, its value is null.

SELF: The self-reference attribute, which is used for the current window object and is synonymous with the window attribute.

Self represents its own window, And opener represents its own window. For example, window a opens window B. If the window. Open method is used, for window B, self represents B, and opener represents window.

This article from the csdn blog, reprinted please indicate the source: written in http://blog.csdn.net/jamestaosh/archive/2009/06/20/4284960.aspx:

2: window. opener is window. the parent Page Object opener is called for a child page opened by open: a reference to the window object that opens the current window. If the current window is opened by the user, its value is null. SELF: The self-reference attribute, which is used for the current window object and is synonymous with the window attribute. Self represents its own window, And opener represents its own window. For example, window a opens window B. If the window. Open method is used, for window B, self represents B, and opener represents window. This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/jamestaosh/archive/2009/06/20/4284960.aspx

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.