We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

2 frames anf javascript

mickael
mickael asked
on
Medium Priority
211 Views
Last Modified: 2008-02-26
Hello,

I have 2 frames and the following javaScript (animated buttons). The left frames has the animated buttons (alway the same frame) and should call the right frames.  When I click on the buttons (left) it loads the page unto the left frame unstead of the right ??

here is the script THANKS!:


<SCRIPT language="JavaScript">
<!--
var bn=navigator.appName;
var vn=navigator.appVersion;
var p1=null;
var p2=null;
var p3=null;
var p4=null;
var p5=null;
// Animated menu stuff
function off_img(loc,img) {};
function on_img(loc,img) {};

function gonow(p)
  {
  location=addr[p];
  };

var addr = new Array(5);
addr[1]="prokiad-intro.html";
addr[2]="selnas-index.html";
addr[3]="presse-index.html";
addr[4]="anglais-index.html";
addr[5]="commande-index.html";
menuimg = new Array(10);
if ((bn!="Microsoft Internet Explorer") || (vn.substring(0,3)!="2.0"))
{
menuimg[1]= new Image (90,53);
menuimg[1].src="prokiad-j-black.jpg";
menuimg[6]= new Image (90,53);
menuimg[6].src="prokiad-v-black.jpg";
menuimg[2]= new Image (90,53);
menuimg[2].src="méthode-j-black.jpg";
menuimg[7]= new Image (90,53);
menuimg[7].src="méthode-v-black.jpg";
menuimg[3]= new Image (90,53);
menuimg[3].src="presse-j-black.jpg";
menuimg[8]= new Image (90,53);
menuimg[8].src="presse-v-black.jpg";
menuimg[4]= new Image (90,53);
menuimg[4].src="anglais-j-black.jpg";
menuimg[9]= new Image (90,53);
menuimg[9].src="anglais-v-black.jpg";
menuimg[5]= new Image (90,53);
menuimg[5].src="commande-j-black.jpg";
menuimg[10]= new Image (90,53);
menuimg[10].src="commande-v-black.jpg";
}

function on_img(loc,img)
  {
  if ((bn!="Microsoft Internet Explorer") || (vn.substring(0,3)!="2.0"))
    loc.src=menuimg[img].src;
  }

// -->
</SCRIPT>
Comment
Watch Question

In the function gonow change

function gonow(p) {
  location=addr[p];
}

to

function gonow(p) {
  framename.location=addr[p];
}

Where framename is the name of the frame you want the html file to be loaded into.

If you have any questions about this ask before grading?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Oops.  I hit the submit button before I was done checking my answer.  The function gonow needs to be changed to

function gonow(p) {
  parent.framename.location=addr[p];
}

I left off the 'parent.' in my first part of the answer.

Author

Commented:

Hello,

I am getting a merror saying parent.framename has no properties

(this URL is the same stuff but    no Frames: http://www.adarweb.com/vs4/index.html)

Here is my entire left button frame HTML giving me the error:




<HTML>
<HEAD><TITLE>Selnas Buttons</TITLE><meta name="resource-type" content="document">


<SCRIPT language="JavaScript">
<!--
var bn=navigator.appName;
var vn=navigator.appVersion;
var p1=null;
var p2=null;
var p3=null;
var p4=null;
var p5=null;
// Animated menu stuff
function off_img(loc,img) {};
function on_img(loc,img) {};

function gonow(p)
  {
parent.framename.location=addr[p];

location=addr[p];
  };

var addr = new Array(5);
addr[1]="prokiad-intro.html";
addr[2]="selnas-index.html";
addr[3]="presse-index.html";
addr[4]="anglais-index.html";
addr[5]="commande-index.html";
menuimg = new Array(10);
if ((bn!="Microsoft Internet Explorer") || (vn.substring(0,3)!="2.0"))
{
menuimg[1]= new Image (90,53);
menuimg[1].src="prokiad-j-black.jpg";
menuimg[6]= new Image (90,53);
menuimg[6].src="prokiad-v-black.jpg";
menuimg[2]= new Image (90,53);
menuimg[2].src="méthode-j-black.jpg";
menuimg[7]= new Image (90,53);
menuimg[7].src="méthode-v-black.jpg";
menuimg[3]= new Image (90,53);
menuimg[3].src="presse-j-black.jpg";
menuimg[8]= new Image (90,53);
menuimg[8].src="presse-v-black.jpg";
menuimg[4]= new Image (90,53);
menuimg[4].src="anglais-j-black.jpg";
menuimg[9]= new Image (90,53);
menuimg[9].src="anglais-v-black.jpg";
menuimg[5]= new Image (90,53);
menuimg[5].src="commande-j-black.jpg";
menuimg[10]= new Image (90,53);
menuimg[10].src="commande-v-black.jpg";
}
function on_img(loc,img)
  {
  if ((bn!="Microsoft Internet Explorer") || (vn.substring(0,3)!="2.0"))
    loc.src=menuimg[img].src;
  }

// -->
</SCRIPT>



</HEAD>
<body background="../../images/gif/side-j.gif" bgcolor="#FFFFFF" vlink="#0000FF" TEXT="#000000" ALINK="#FF0000">




<table border=0>
<tr>
      <td>

<table border=0 valign="center">
<tr>
      
<td>

<a href="javascript:gonow(1) " target="left_window" onMouseOver="on_img(p1,6);self.status='Les laboratoires Prokiad';return true"onMouseOut= "on_img(p1,1);self.status='Les laboratoires Prokiad';return true">
<img src="prokiad-j-black.jpg" name="p1" alt="Les laboratoires Prokiad" border=0 width="90" height="53"></a>
      </td>

<tr>
      <td>
<a href="javascript:gonow(2)" onMouseOver="on_img(p2,7);self.status='La méthode S.E.L.N.A.S';return true"onMouseOut= "on_img(p2,2);self.status='La méthode S.E.L.N.A.S';return true">
<img src="méthode-j-black.jpg" name="p2" alt="la méthode S.E.L.N.A.S" border=0 width="90" height="53"></a>
      </td>
</tr>

<tr>
      <td>
<a href="javascript:gonow(3)" onMouseOver="on_img(p3,8);self.status='La presse et S.E.L.N.A.S';return true"onMouseOut= "on_img(p3,3);self.status='La presse et S.E.L.N.A.S';return true">
<img src="presse-j-black.jpg" name="p3" alt="La presse et S.E.L.N.A.S" border=0 width="90" height="53"></a>
      </td>
</tr>

<tr>
<td><a href="javascript:gonow(4)" onMouseOver="on_img(p4,9);self.status='Le site S.E.L.N.A.S en Anglais';return true"onMouseOut= "on_img(p4,4);self.status='Le site S.E.L.N.A.S en Anglais';return true">
<img src="anglais-j-black.jpg" name="p4" alt="Le site S.E.L.N.A.S en Anglais" border=0 width="90" height="53"></a>
      </td>
</tr>

<tr>
      <td>
<a href="javascript:gonow(5)" onMouseOver="on_img(p5,10);self.status='Commandez votre calenndrier ON LINE';return true"onMouseOut= "on_img(p5,5);self.status='Commandez votre calenndrier ON LINE';return true">
<img src="commande-j-black.jpg" name="p5" alt="Commandez votre calendrier ON LINE" border=0 width="90" height="53"></a>
      </td>
</tr>
</table>


      </td>

</tr>
</table>



</BODY>
</HTML>


Oops!  It seems as though you used parent.framename.location=addr[p] exactly as I said.  Sorry, you misunderstood.  You need to change 'framename' to whatever your right frame name is called.  You may have called it 'right_frame'.  If so then you would use parent.right_frame.location=addr[p]

Let me know if this works.

I did find some things that need to be fixed:
line 89 - remove <TR>
line 185 - remove <TD>
line 195 - add </TR>

I would also suggest using an HTML validator program.  I found about 30 other minor errors.  You can find a validator at http://www.htmlvalidator.com .  It's shareware and you can use it 150 times before it disables itself.
Note:  The above errors were find on the URL you posted.
Did my answer work?  If so please grade.  If not, what problem is occuring?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.