JavaScript's Frame Path
Frameset with sample code
JavaScript treats each frame as a separate window, so you have as much control over an individual page within a frameset as you would with a regular window. You can write to a frame, change its background color, or reference a form field contained in a frame, all from another page. The part that is different is the path.

A frameset page (the page declaring the structure and source files of an entire frameset) is known to JavaScript as parent. To access any page contained within the frameset, you must start with a reference to its parent. After the parent reference, just declare the frame's name (the HTML name attribute's value that is assigned in the frameset page), then any property or object available to it. NOTE: Framesets are also considered an array, so array syntax with either integer indices or associative indices can be used as path references.

The single window containing the parent document and each of its child frames is known as top. Top's location can be, and usually is, a frameset's parent page. However, if you are dealing with nested framesets -when the source of a frame contained in a frameset is actually another frameset- a reference to the parent of a page within the nested frameset is not the same as a reference to the top. Be careful not to confuse the top reference with the parent reference if your site contains nested framesets.

The Golden Rule
When referencing a different frame, the reference must begin with the window the two have in common - be it parent or top.

Note: Pop up windows: if a frame in a frameset launches a new window, that new window also has access to any frame in the frameset by, "opener.parent.FrameName".
Note: Nested Framesets: a frame within a nested frameset has access to a frame in the main frameset by, "parent.parent.FrameName".

Take a look at the sample frameset page.


View Source | Home | Contact