bHi all.

I am, using Java for drop down menus, code follows. What I have not yet been able to figure out is how to make java display the page I select in a different frame. This is what is in the <HEAD> of one of my Pages.

<SCRIPT language="JavaScript">

function navigate(form) 
{
 var go = (form.linkList.options[form.linkList.selectedIndex].value);
 document.location.href=go;
}
</SCRIPT>

My Frames page structure is as follows:

<html>

<head>
<title>Jim's Model Collection</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<frameset rows="52,*" framespacing="0" border="0" frameborder="0">
  <frame name="header" scrolling="no" noresize target="contents" src="header.html">
  <frameset cols="247,*">
    <frame name="nav" target="main" src="metnav.htm" scrolling="auto" noresize>
    <frame name="main" src="metlogo.html" scrolling="auto" noresize target="main">
  </frameset>
  <noframes>
  <body>

  <p>This page uses frames, but your browser doesn't support them.</p>

  </body>
  </noframes>
</frameset>

</html>

The following is a sample menu:

<FORM METHOD=post>
	<img src="food/images/decades.gif" width="161" height="44">
	<br>
	<SELECT NAME="linkList" onChange="navigate(this.form)">
		<OPTION Value="">Select
		<OPTION Value="30nav.htm">1930s
		<OPTION Value="40nav.htm">1940s
		<OPTION Value="50nav.htm">1950s
		<OPTION Value="60nav.htm">1960s
		<OPTION Value="70nav.htm">1970s
		<OPTION Value="80nav.htm">1980s
		<OPTION Value="90nav.htm">1990s
                  </OPTION>
	</SELECT>
</FORM>

Using the above menu, how would I make 30nav.htm display in the main frame? I have tried <base target=main> in the <HEAD>, and that did not work. In some instances, I would want it to, how to I put this so everyone understands, use target=top so I get a new display, for example, I want to load a different frames page with different menus, and filler pages. Is what I'm trying to do even possible? Does everyone understand what I'm trying to do?

Thanks.

Jim.

Recommended Answers

All 2 Replies

As per what my understanding of the problem goes, setting the attribute 'target' wont help because the form is not submitting any form. You are just changing location in the navigate() javascript function.
You can achieve what you want by changing the line

document.location.href=go;

in the navigate() javascript function by

parent.main.location=go;

In the above line the parent object is used because the navigation script will loaded in some frame and than 'main' is the name of the target frame.

Hope this was useful

As per what my understanding of the problem goes, setting the attribute 'target' wont help because the form is not submitting any form. You are just changing location in the navigate() javascript function.
You can achieve what you want by changing the line

document.location.href=go;

in the navigate() javascript function by

parent.main.location=go;

In the above line the parent object is used because the navigation script will loaded in some frame and than 'main' is the name of the target frame.

Hope this was useful

Actually that did work, thank you. I can use it on some of my pages, but all of the pages will load in main. I was looking for something more individual like for example in each Hyperlink I can define the target frame as main (to load it in the main frame), or _top (to escape frames, and load new frames page), or _blank (to open a new window), or define no target (to load it in the current frame). Is that possible? If not, I'll just see if I can't come up with something else.

Thanks,
Jim.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.