November 7, 1999 - Window References | WebReference

November 7, 1999 - Window References

Yehuda Shiran November 7, 1999
Window References
Tips: November 1999

Yehuda Shiran, Ph.D.
Doc JavaScript

When working with frames, you must be familiar with the JavaScript connection between the frames. Each frame is represented by its own window object. The window object of a child frame is actually a property of the parent's window object.

The self property retrieves a reference to the current window or frame. The parent property retrieves the parent of the window in the object hierarchy. Finally, the top property retrieves the topmost ancestor window, which is its own parent. In other words, if self is equal to self.parent, then the current window doesn't have a parent, meaning it is the topmost window. In this case, self is also equal to self.top. The following diagram illustrates the usage of these window references:

The window Hierarchy

Note that recursive references are possible. For example, window.window.window evaluates to window, which is also equivalent to self.self.self.