Solved

Targeting multiple Iframes with one link.

Posted on 2004-08-22
11
278 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
Comment Utility
function doTwo(A,B)
{
top.frames['pageA'].location.href=A;
top.frames['pageB'].location.href=B;
}

Cd&
0
 

Author Comment

by:Pharcyde616
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Pharcyde616
Comment Utility
Doesnt seem to work...says error on page.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 63

Accepted Solution

by:
Zvonko earned 125 total points
Comment Utility
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
Comment Utility
Thanks worked great!
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
You are welcome.
0
 

Author Comment

by:Pharcyde616
Comment Utility
<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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now