Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Targeting multiple Iframes with one link.

Posted on 2004-08-22
11
282 Views
Last Modified: 2012-08-14
Hello,

I am trying to do a basic solution for work in which I have one link that targets two seperate Iframes. Lets say I click on the link "search engines" ... it will display google in Iframe A and yahoo in Iframe B. Heres some code I found on the internet but I dont know much about Javascript, how do I get it working..it keeps giving me an error.  I do not know anything about javascript so I may have even set up the variables or script type wrong.  

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type= javascript>
function doTwo(pageA,pageB)
{
(numberoneIframe.location=pageA);
(numberTwoIframe.location=pageB);
}
</script>
</head>
<body>
<a href="javascript:doTwo('google.com','yahoo.com')">Change Two iframes</a>


<table width="295" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="295" height="105" valign="top"><iframe name="pageA"></iframe><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="105" valign="top"><iframe name="pageB"></iframe><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
</table>
</body>
</html>


Any help would be greatly appreciated!
0
Comment
Question by:Pharcyde616
  • 5
  • 3
  • 3
11 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11864425
function doTwo(A,B)
{
top.frames['pageA'].location.href=A;
top.frames['pageB'].location.href=B;
}

Cd&
0
 

Author Comment

by:Pharcyde616
ID: 11865467
I'm sorry I dont know where to put this in and how to adjust the additional code...as I said..very new to javascript..
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11865794
You just replace this:

function doTwo(pageA,pageB)
{
(numberoneIframe.location=pageA);
(numberTwoIframe.location=pageB);
}

With this:
 function doTwo(A,B)
{
top.frames['pageA'].location.href=A;
top.frames['pageB'].location.href=B;
}

Cd&
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Pharcyde616
ID: 11865827
Doesnt seem to work...says error on page.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11865859
What is the error?

Go to the tools menu >>> internet options... >>> advanced tab, and check the box for
"Display notification for every script error"

Then it will display the text of the error.

Cd&
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 125 total points
ID: 11866274
There was a basic error in type definition of the script tag.

Here a revised version:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language= javascript>
function doTwo(locA,locB) {
  window.frames.pageA.location=locA;
  window.frames.pageB.location=locB;
}
</script>
</head>
<body>
<a href="javascript:doTwo('http://google.com','http://yahoo.com')">Change Two iframes</a>
<table width="295" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="295" height="105" valign="top"><iframe name="pageA"></iframe><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="105" valign="top"><iframe name="pageB"></iframe><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
</table>
</body>
</html>


0
 

Author Comment

by:Pharcyde616
ID: 11866436
Thanks worked great!
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11866458
You are welcome.
0
 

Author Comment

by:Pharcyde616
ID: 11867795
<a href="javascript:doTwo('http://google.com','http://yahoo.com')">Change Two iframes</a>

hey I was wondering why if i put in a location on my hard drive it will not work when it usually does without the multiple point

<a href="javascript:doTwo('c:\' ,'http://yahoo.com')">Change Two iframes</a>
0
 

Author Comment

by:Pharcyde616
ID: 11867950
got that working...but how do you use this code from one

iframe that has the links to the other three iframes.... this works if the link is on the same page as the iframes but what if is from iframe to iframe?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11868384
I did not understood your last question. But definitely you will get problems when READING attributes from a foreign internet domain.
Assigning a location is not reading, it is writing. But after assigning "http://gogle.com" to an iframe you cannot access anyithing from that iframe.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

861 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