14.8.2 Relationships Between Frames
As we saw above, the open()method of a Window object returns a new Window object that has an opener property that refers back to the original window. In this way, the two windows can refer to each other, and each can read properties and invoke methods of the other. A similar thing is possible with frames. Code running in a window or frame can refer to the containing window or frame and to nested child frames using the properties described below.
A Window object that represents a top-level window or tab has no container, and its parent property simply refers to the window itself:
parent == self; // For any top-level window
If a frame is contained within another frame that is contained within a top-level window, that frame can refer to the top-level window as parent.parent. The top property is a general-case shortcut, however: no matter how deeply a frame is nested, its top property refers to the top-level containing window. If a Window object represents a top-level window, top simply refers to that window itself. For frames that are direct children of a top-level window, the top property is the same as the parent property.
The parent and top properties allow a script to refer to its frame’s ancestors. There is more than one way to refer to the descendant frames of a window or frame. Frames are created with欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/27912.html