Business web hosting - CD-101Chapter 11 .Scripting Frames and Multiple Windows It
Monday, August 27th, 2007CD-101Chapter 11 .Scripting Frames and Multiple Windows It is often difficult at first to visualize the frameset as a window object in the hier archy. After all, with the exception of the URL showing in the Location/Address field, you don t see anything about the frameset in the browser. But that window object exists in the object model. Notice, too, that in the diagram the framesetting parent window has no document object showing. This may also seem odd because the window obviously requires an HTML file containing the specifications for the frameset. In truth, the parent window has a document object associated with it, but it is omitted from the diagram to better portray the relationships among parent and child windows. A frameset parent s document cannot contain most of the typical HTML objects such as forms and controls, so references to the parent s document are rarely, if ever, used. If you add a script to the framesetting document that needs to access a property or method of that window object, references are like any single-frame situation. Think about the point of view 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 frames contains a document object whose content you see in the browser window. And the structure is such that each document is entirely independent of the other. It is as if each document lived in its own browser window. Indeed, that s why each child frame is also a window type of object. A frame has the same kinds of properties and methods of the window object that occupies the entire browser. From the point of view of either child window in Figure 11-2, its immediate container is the parent window. When a parent window is at the very top of the hierarchical model loaded in the browser, that window is also referred to as the top object. References among Family Members Given the frame structure of Figure 11-2, it s time to look at how a script in any one of those windows can access objects, functions, or variables in the others. An important point to remember about this facility is that if a script has access to an object, function, or global variable in its own window, that same item can be reached by a script from another frame in the hierarchy (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 hierarchy described so far: parent to child; child to parent; or child to child. Each of the paths between these windows requires a different reference style. Parent-to-child references Probably 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 or more frames, which means the parent maintains an array of the child frame objects. You can address a frame by array syntax or by the name you assign to it with the NAMEattribute inside the tag. In the following exam ples of reference syntax, I substitute a placeholder named ObjFuncVarName for whatever object, function, or global variable you intend to access in the distant window or frame. Remember that each visible frame contains a document object,
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.