Java Reference
In-Depth Information
Yes, you're right. You could have used window.top instead, and this would have been a better way to
do it. We're doing it the long way here just to demonstrate how the hierarchy works.
Now you move down the hierarchy, but on the other side of your tree diagram, to reference the
frameMenu 's window object.
window.parent.parent.frameMenu
Finally, you are interested only in the form and its controls, so you reference that object like this:
window.parent.parent.frameMenu.document.form1
Now that you have a reference to the form, you can use it just as you would if this were code in
frameMenu itself.
The function's parameter linkIndex tells you which of the four links was clicked, and you use this
value in the next line of the function's code to set which of the options is selected in the drop-down list
box on frameMenu's for m.
formobject.choosePage.selectedIndex = linkIndex;
The if...else statement is where you set the frameMenu 's radio button group radFrame to the frame
the user just clicked on, but how can you tell which frame this is?
if (window.parent.frameTop == window.self)
{
formobject.radFrame[0].checked = true
}
else
{
formobject.radFrame[1].checked = true
}
You check to see whether the current window object is the same as the window object for frameTop. You
do this using the self property of the window object, which returns a reference to the current window
object, and window.parent.frameTop, which returns a reference to frameTop's window object. If one
is equal to the other, you know that they are the same thing and that the current window is frameTop.
If that's the case, the radFrame radio group in the frameMenu frame has its fi rst radio button checked.
Otherwise, you check the other radio button for frameBottom.
The last thing you do in the function is return true . Remember that this function is connected to an
A object, so returning false cancels the link's action, and true allows it to continue, which is what
you want.
return true;
}
Scripting IFrames
Inline frames (iframes), introduced by Microsoft in Internet Explorer (IE) 3, became a part of the HTML
standard in HTML 4. They're a unique element in that you can add a frame to a web page without using
a frameset, and they're much simpler to add to the page because of it. For example:
<iframe name=”myIFrame” src=”child_frame.htm” />
Search WWH ::




Custom Search