Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Targeting multiple Iframes with one link.

Posted on 2004-08-22
11
Medium Priority
?
286 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

670 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