Solved

Java Programming question

Posted on 1997-07-28
12
177 Views
Last Modified: 2010-04-16
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!
0
Comment
Question by:kerbe
  • 6
  • 6
12 Comments
 
LVL 3

Accepted Solution

by:
garik earned 0 total points
ID: 1223920
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
 

Author Comment

by:kerbe
ID: 1223921
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
 
LVL 3

Expert Comment

by:garik
ID: 1223922
"Absolute" reference should help:

  top.Right.location.href=...


0
 

Author Comment

by:kerbe
ID: 1223923
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
 
LVL 3

Expert Comment

by:garik
ID: 1223924
Yeah, that would be nice :)
0
 

Author Comment

by:kerbe
ID: 1223925
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 3

Expert Comment

by:garik
ID: 1223926
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
 

Author Comment

by:kerbe
ID: 1223927
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
 
LVL 3

Expert Comment

by:garik
ID: 1223928
Try it one more time in the morning :)
0
 

Author Comment

by:kerbe
ID: 1223929
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
 
LVL 3

Expert Comment

by:garik
ID: 1223930
Everything seems to work fine in MSIE.
Congrats!
0
 

Author Comment

by:kerbe
ID: 1223931
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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now