123Chapter 11Scripting Frames (Managed web hosting) and Multiple WindowsIt is often

123Chapter 11Scripting Frames and Multiple WindowsIt is often difficult at first to visualize the frameset as a window object in the hierarchy. Afterall, with the exception of the URL showing in the Location/Address field, you don t seeanything about the frameset in the browser. But that window object exists in the objectmodel. Notice, too, that in the diagram the framesetting parent window has no documentobject showing. This may also seem odd because the window obviously requires an HTMLfile containing the specifications for the frameset. In truth, the parent window has a documentobject associated with it, but it is omitted from the diagram to better portray the relation- ships among parent and child windows. A frameset parent s document cannot contain mostof the typical HTML objects such as forms and controls, so references to the parent s docu- ment are rarely, if ever, used. If you add a script to the framesetting document that needs to access a property or methodof that window object, references are like any single-frame situation. Think about the point ofview of a script located in that window. Its immediate universe is the very same window. Things get more interesting when you start looking at the child frames. Each of these framescontains a documentobject whose content you see in the browser window. And the structureis such that each frame s document is entirely independent of the other. It is as if each docu- ment lived in its own browser window. Indeed, that s why each child frame is also a windowtype of object. A frame has the same kinds of properties and methods of the windowobjectthat occupies the entire browser. From the point of view of either child window in Figure 11-2, its immediate container is theparentwindow. When a parentwindow is at the very top of the hierarchical model loaded inthe browser, that window is also referred to as the topobject. References among Family MembersGiven the frame structure of Figure 11-2, it s time to look at how a script in any one of thosewindows can access objects, functions, or variables in the others. An important point toremember about this facility is that if a script has access to an object, function, or global vari- able in its own window, that same item can be reached by a script from another frame in thehierarchy (provided both documents come from the same Web server). A script reference may need to take one of three possible routes in the two-generation hierar- chy described so far: parent to child; child to parent; or child to child. Each of the pathsbetween these windows requires a different reference style. Parent-to-child referencesProbably the least common direction taken by references is when a script in the parent document needs to access some element of one of its frames. The parent contains two ormore frames, which means the parent maintains an array of the child frame objects. Youcanaddress a frame by array syntax or by the name you assign to it with the nameattributeinside the tag. In the following examples of reference syntax, I substitute a placeholdernamed ObjFuncVarNamefor whatever object, function, or global variable you intend to accessin the distant window or frame. Remember that each visible frame contains a documentobject, which is generally the container of elements you script be sure references to the elementsinclude document. With that in mind, a reference from a parent to one of its child frames fol- lows any of these models:
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services

Leave a Reply