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>