Home  >  Article  >  Web Front-end  >  Introduction to the meaning of top, parent, and opener of JS window object_javascript skills

Introduction to the meaning of top, parent, and opener of JS window object_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:11:001157browse

1.top
This change always refers to the browser window at the top level of the split window. If you plan to execute commands from the highest level of the split window, you can use the top variable.
2.opener
opener is used in the window.open page to reference the object of the page that executes the window.open method. For example: Page A pops up page B through the window.open() method. In page B, page A can be referenced through opener, so that page A can be operated through this object.
3.parent
parent is used to access the object of the parent page in the child page generated in the iframe or frame. For example: If there is an iframe or frame in page A, then the page in iframe
or frame can refer to the object in page A through the parent object. In this way, the value can be obtained or returned to the A page.
4. In addition, self refers to the current window

The difference between parent and opener:

Parent refers to the parent window. In FRAMESET, the PARENT of FRAME is the FRAMESET window.

opener refers to the original window corresponding to the new window created using WINDOW.OPEN and other methods.
parent is the parent window object relative to the frame
opener is the parent window for the window opened with window.open, provided that window.open is opened

document.parentWindow.menthod() calls the method of the parent page

Attachment: The hierarchical relationship between Window object, Parent object, Frame object, Document object and Form object

Window object→Parent object→Frame object→Document object→Form object,
as follows: parent.frame1.document .forms[0].elements[0].value;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn