124Part IIJavaScript Tutorial[window.]frames[n].ObjFuncVarName[window.]frames[ frameName ].ObjFuncVarName[window.]frameName.ObjFuncVarNameNumeric index values for frames are (Web server setup)

124Part IIJavaScript Tutorial[window.]frames[n].ObjFuncVarName[window.]frames[ frameName ].ObjFuncVarName[window.]frameName.ObjFuncVarNameNumeric index values for frames are based on the order in which their tags appearin the framesetting document. You will make your life easier, however, if you assign recogniz- able names to each frame and use the frame s name in the reference. Child-to-parent referencesIt is not uncommon to place scripts in the parent (in the Head portion) that multiple childframes or multiple documents in a frame use as a kind of script library. By loading in theframeset, these scripts load only once while the frameset is visible. If other documents fromthe same server load into the frames over time, they can take advantage of the parent sscripts without having to load their own copies into the browser. From the child s point of view, the next level up the hierarchy is called the parent. Therefore, a reference from a child frame to items at the parent level is simplyparent.ObjFuncVarNameIf the item accessed in the parent is a function that returns a value, the returned value tran- scends the parent/child borders down to the child without hesitation. When the parent window is also at the very top of the object hierarchy currently loaded intothe browser, you can optionally refer to it as the top window, as intop.ObjFuncVarNameUsing the topreference can be hazardous if for some reason your Web page gets displayed insome other Web site s frameset. What is your top window is not the master frameset s topwindow. Therefore, I recommend using the parentreference whenever possible (unless youwant to blow away an unwanted framer of your Web site). Child-to-child referencesThe browser needs a bit more assistance when it comes to getting one child window to com- municate with one of its siblings. One of the properties of any window or frame is its parent(whose value is nullfor a single window). A reference must use the parentproperty to workits way out of the current frame to a point that both child frames have in common the par- ent in this case. Once the reference is at the parent level, the rest of the reference can carryon as if starting at the parent. Thus, from one child to one of its siblings, you can use any ofthe following reference formats: parent.frames[n].ObjFuncVarNameparent.frames[ frameName ].ObjFuncVarNameparent.frameName.ObjFuncVarNameA reference from the other sibling back to the first looks the same, but the frames[]arrayindex or frameNamepart of the reference differs. Of course, much more complex frame hier- archies exist in HTML. Even so, the object model and referencing scheme provide a solutionfor the most deeply nested and gnarled frame arrangement you can think of following thesame precepts you just learned.