
There are many variations of combo menus and today I will
walk you through how to make a combo menu that loads a selected URL into a separate frame. I know some people who find the whole thing difficult but it's really quite simple. Before we get to our task for today, first you need to realize the two things which need to be accomplished: First, assign a name to every frame by using name attribute placed inside the tag
. Second, use the name of the frame as a substitute for "location" in the function go(). Here's a visual on what you need to do first:
<html>
<frameset cols="30%,70%">
<frame src="page1.htm" name="Jack">
<frame src="page2.htm" name="Jill">
</frameset>
</html>
The name is necessary before you can specify which frame you want the URL to be loaded in. Once you have done that, modifying the combo code is the next step. By modifying the combo code, you tell the JavaScript to target the frame that you desire. Let's assume that the
combo code is located on page1.htm and you want the targeted URL to be loaded on page2.htm, here's the code that you need:
<script type="text/javascript">
<!--
function go(){
parent.Jane.location=
document.mycombo.example.
options[document.mycombo.example.selectedIndex].value
}
//-->
</script>
"Parent" is the keyword in this code. This object will represent the frames page's parent window. It has to be written as a prefix, because you need to walk one level up so that you can reach page2.htm. The keyword is followed by the name which signifies the name of the
page frame location.
Comments