Solved

Java Programming question

Posted on 1997-07-28
12
179 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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
 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 99
varialbe initialization 11 35
hibernate insert example 13 29
Desingning Refactoring existing code 2 24
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

825 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