Java Programming question

In the following script, the button is supposed to call a new page of html to open in another frame on the same page as the button.

The "target=" seems to me to be in the correct place, but the files open in the same frame as the button. What am I missing?

<script language="JavaScript">

<!-- Cloak code
function leapto(form)
   {
   var site=form.go.selectedIndex;
   if (site==0)
      alert("Choose something!");
   if (site>=1)
      { location=form.go.options[site].value; }
   }
// Decloak -->
</script>


<form>
<select name="go" size="1">
<option value selected>INDEX</option>
<option value="kerbe2.htm">Biography</option>
<option value="kerbe3.htm">Projects</option>
<option value="kerbe4.htm">Quote</option>
<option value="kerbe5.htm">Portfolio</option>
<option value="kerbe6.htm">Links</option>
<option value="kerbe7.htm">Contact</option>
</select>

<br>
<br>

<input type="button" value="Visit"
            onclick="leapto(this.form)" target="Right">

</form>

Thanks!
kerbeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

garikCommented:
To specify a target frame in a multi-frame page (constructed using FRAMESET tags), use location.href property of the corresponding frame. F.ex., if the main page contains

<FRAMESET ...>
   <FRAME NAME=Left SRC=Left.html>
   <FRAME NAME=Right SRC=Right.html>
</FRAMESET>

then you could use

if (site>=1)
 Right.location.href=form.go.options[site].value;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kerbeAuthor Commented:
Garik:

I entered the code you proposed and rewrote my <frameset> tags to your specifications (they had been <frame src="x.htm" name="right").

I now get a javascript runtime error window telling me that "Right" (in your new line of code) is undefined.

Am I missing something?
0
garikCommented:
"Absolute" reference should help:

  top.Right.location.href=...


0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

kerbeAuthor Commented:
Aha. Ok, now the popup window tells me that " 'Right' is not an object."

Would you like to see the HTML for all the pages involved?
0
garikCommented:
Yeah, that would be nice :)
0
kerbeAuthor Commented:
Okey, dokey!

****FRAME PAGE

<HTML>
<HEAD>
<TITLE>Life Upon the Wicked Stage...</TITLE>
</HEAD>
<frameset cols="20%,80%" frameborder=0 framespacing=0 border=0>
  <frame name=Left SRC="index.htm" noresize>
  <frame name=Right SRC="kerbe1.htm" noresize>
 </frameset>
<body vlink="#ff8000" link="#800080" alink="#00ff00" text="#000080" bgcolor="#ffffff">
<font face="arial,helvetica">
<bgsound src="midi/peace.mid" loop=6>

</font>
</body>
</HTML>

****INDEX PAGE

<HTML>
<HEAD>
<TITLE>INDEX</TITLE>
</HEAD>

<script language="JavaScript">

<!-- Cloak code
function leapto(form)
   {
   var site=form.go.selectedIndex;
   if (site==0)
      alert("Choose something!");
   if (site>=1)
      top.Right.location.href=form.go.options[site].value;
   }
// Decloak -->
</script>


<form target="Right">
<select name="go" size="1">
<option value selected>INDEX</option>
<option value="kerbe2.htm">Biography</option>
<option value="kerbe3.htm">Projects</option>
<option value="kerbe4.htm">Quote</option>
<option value="kerbe5.htm">Portfolio</option>
<option value="kerbe6.htm">Links</option>
<option value="kerbe7.htm">Contact</option>
</select>

<br>
<br>

<input type="button" value="Visit"
            onclick="leapto(this.form)">

</form>

<script language="JavaScript">

var scrtxt="This site is optimized for MS Internet Explorer     ...     "+
"Current Update:  July 26, 1997";
var lentxt=scrtxt.length;
var width=120;
var pos=1-width;

function scroll() {
  pos++;
  var scroller="";
  if (pos==lentxt) {
    pos=1-width;
  }
  if (pos<0) {
    for (var i=1; i<=Math.abs(pos); i++) {
      scroller=scroller+" ";}
    scroller=scroller+scrtxt.substring(0,width-i+1);
  }
  else {
    scroller=scroller+scrtxt.substring(pos,width+pos);
  }
  window.status = scroller;
  setTimeout("scroll()",50);
  }
//-->
</script>



<body vlink="#ff8000" link="#800080" alink="#00ff00" text="#000080" bgcolor="#ffffff" onLoad="scroll();return true;">

<font face="arial,helvetica">

<table>
<font size=-2><img align=left src="http://www.tcp-ip.com/scripts/count.exe?width=6&link=kerbe&style=simple&bgcolour=trans&fgcolour=000000&inc=1">
</table>
<br>
<a href="http://www.microsoft.com/ie/">
<img align=left src="art/ie_animated.gif" alt="MSIE" border=0></a>
</font>
</BODY>
</HTML>


0
garikCommented:
I can't find the problem - it works for me in both Netscape  and MSIE (both 3.01). Do you have all the kerbe?.htm files (or at least one, kerbe1.htm)?

I've just copied your code from this page to the corresponding files, add blank kerbe1.htm, kerbe2.htm, and it works.

Although TARGET attribute in the FORM tag is extra, and the whole FORM construct belongs inside the BODY tags, it still works.

Please check file names and, perhaps,  try Netscape.
0
kerbeAuthor Commented:
Thanks for all your help. I've tried various permutations, loading each to my ISP and accessing them online and it always goes kahflooey -- in both MSIE and Netscape.

Maybe it's me, but no matter what I get those blasted Javascript problem windows.

:o)

Thanks for all your help.
0
garikCommented:
Try it one more time in the morning :)
0
kerbeAuthor Commented:
Couldn't wait 'til morning -- And BY GOD IT WORKS!

Check it out: http://www.tcp-ip.com/kerbe

Netscape issues... animated GIFs play only once, EMBEDed midi file doesn't want to play, graphics seem to anchor wherever they choose, colors don't match. After 4 years of it, I switched to MSIE.
0
garikCommented:
Everything seems to work fine in MSIE.
Congrats!
0
kerbeAuthor Commented:
That's MSIE for you -- takes a licking and keeps on ticking. Netscape, on the other hand, now refuses to play an <EMBED>ed MIDI file and runs animated GIFs only once. I'm wondering if either of these things is in conflict with Javascript...

Hardly seems likely, though. But, then again, we're talking about Netscape...

:o)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.