Solved

Change two iFrames with one link

Posted on 2012-03-21
5
396 Views
Last Modified: 2012-04-19
Is there a way to make two iframes change to different pages with one external link on the main page? I want to make a page show one image and one content with the click. I have both frames working but the user has two click two different links. Is there a away to make one link change both at the same time?
0
Comment
Question by:Turfimage
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:bigeven2002
Comment Utility
Hello,

Changing 2 iframe sources with one click would require javascript.

<html>
<body>
<script language="javascript" type="application/javascript">
function framechange(x,y){
    document.getElementById('iframe1').src = x;
    document.getElementById('iframe2').src = y;
}
</script>

<p>
<a href="#" onclick="framechange('image.jpg','content.html');">Click here to change iframes</a>
</p>

<iframe id="iframe1" src="" width="250" height="250" ></iframe>
<br /><br />
<iframe id="iframe2" src="" width="250" height="250" ></iframe>

</body>
</html>

Open in new window


The parameters are relative path to the main document.  You can put an absolute path in there if you wanted as well.
0
 

Author Comment

by:Turfimage
Comment Utility
What if I had two iframez "iframez" and "iframezTOC" and I wanted one link "Read" to change both the iframez?

Would I change this? I cant seem to get it to work right.

document.getElementById('iframe1').src = x;
document.getElementById('iframe2').src = y;
0
 
LVL 17

Expert Comment

by:bigeven2002
Comment Utility
Can you post the full code you are currently trying?
0
 

Author Comment

by:Turfimage
Comment Utility
http://timapserver.com/lettis/ceus-ssc-2/Report/Chapter1.html
Here is the site I left the java script but took out the link code so it would work for now... I'm trying to make the "HTML" link on the right open both iframez at once... The larger reading pane is called "iframez" and the navigation is called "iframezTOC". If you open the PDF link or search link you will see that the HTML link needs to open both the chapter.HTML and the table of contents HTML. Thank you for your help
0
 
LVL 17

Accepted Solution

by:
bigeven2002 earned 200 total points
Comment Utility
Thanks for posting, but since you took the link code out, I can't see the error.  Looking at the anchor tag for View HTML though, this should work:
<a href="#" onclick="framechange('Chapter1/1Info.html','Chapter1/1TOC.html');"> View HTML</a>

Open in new window


If this failed last time like this, maybe the arguments are pointing to the wrong path.  You might need to make the path absolute:
<a href="#" onclick="framechange('/lettis/ceus-ssc-2/Report/Chapter1/1Info.html','/lettis/ceus-ssc-2/Report/Chapter1/1TOC.html');"> View HTML</a>

Open in new window

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

New Relic recently released its Synthetics product that allows for the creation of performance monitors that periodically test a site's performance. If you wish to test an interactive workflow New Relic employs Selenium WebDriverJS to run those test…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

763 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

7 Experts available now in Live!

Get 1:1 Help Now