Overview and case applications of top/parent/frame in js

Source: Internet
Author: User

Reference Method top:
This variable always refers to the browser window at the highest level. 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.
Appendix: class relationships between Window objects, Parent objects, Frame Objects, Document objects, and Form objects

Windwo object → Parent object → Frame object → Document Object → Form object, as follows:
Parent.frame1.doc ument. forms [0]. elements [0]. value;
In JS: window. location (window. location. href) and window. top. location (window. top. location. href) means that you can call any frame through top, because top refers to the outermost frameset and can call any sub-element frame in it. For example, top. outterFrame1.location and top. innerFrame2.location.

Parent refers to the parent window (frameset) of the current window (frame) which can call any sub-element frame in it. For example, parent. innerFrame1.location and parent. innerFrame2.location.
Copy codeThe Code is as follows:
<Html>
<Head>
<Title> top frame parent example </title>
<Script language = "javaScript" type = "text/javaScript">
Window. location. href = "http://www.baidu.com /";
</Script>
</Head>
<Frameset id = "outFrameset" rows = "150, *, 150" cols = "*" border = "5">
<Frame name = "frameName1" id = "frameId1" src = "a.html">
<Frameset id = "inFrameset" cols = "150, *" rows = "*">
<Frame name = "innerFrameName1" id = "innerFrameId1" src = "a.html">
<Frame name = "innerFrameName2" id = "innerFrameId2" src = "a.html">
</Frameset>
<Frame name = "frameName2" id = "frameId2" src = "a.html">
</Frameset>
</Html>

Related Article

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.