Solved

Targeting multiple Iframes with one link.

Posted on 2004-08-22
11
285 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses

636 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