220 Part III . Document Objects (Web site templates) Reference Top

220 Part III . Document Objects Reference Top Parent Child Frame Document Child Frame Child Frame Document Child Frame Parent Document Figure 16-3: Three generations of window objects Referencing frames The purpose of an object reference is to help JavaScript locate the desired object in the object model currently held in memory. A reference is a road map for the browser to follow, so that it can track down, say, the value of a particular text field in a particular document. Therefore, when you construct a reference, think about where the script appears in the object model and how the reference can help the browser determine where it should go to find the distant object. In a two-generation scenario, such as the one shown in Figure 16-2, three intergenerational references are possible: . Parent-to-child . Child-to-parent . Child-to-child Assuming that you need to access an object, function, or variable in the relative s frame, the following are the corresponding reference structures: . frameName.objFuncVarName . parent.objFuncVarName . parent.frameName.objFuncVarName The rule is this: Whenever a reference must point to another frame, begin the reference with the window object that the two destinations have in common. To demonstrate that rule on the complex model in Figure 16-3, if the left-hand child frame s document needs to reference the document at the bottom right of the map, the reference structure is top.frameName.frameName.document. … Follow the map from the top windowobject down through two frames to the final document. JavaScript has to take this route, so your reference must help it along.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Leave a Reply