PDA

View Full Version : Need help with Iframe Linking



JustSumNJguy
03-03-2005, 08:33 PM
Ok, heres my situation. I will also add a picture to show you what I a talking about.

http://img133.exs.cx:81/img133/3701/gacsite0bx.gif

OK, I am making a website for my cousins band. As you can see above that will be the basic lay out. There are 3 Iframes on the site Iframe 1 is where you see the welcome area, Iframe 2 is where it says "Test Are2" and Iframe 3 is where it says "Test Are 3".

Now for the most part Iframe 2 and 3 will not be used, But only in their music section. Now what I would like to happen is this. Somone clicks the Mutimedia link from the main images. A list will appear in Iframe 2 (This I am able to already do). Now this is where my problem is. I want to make it so that when the person clicks the link from Iframe 2 that a page loads in Iframe 1 and also another page (completely differen't) loads in Iframe 3. I am just not sure how to code for this to happen.

Basily I want to be able to open up 2 differen't pages in 2 differen't Iframes with 1 link. I have tried most of the coding tricks I know and none seem to work. I have searched the web and the best I have seen so far is using Java to do this (And that auther wasn't even sure it would work). So you know, I don't know anything about Java or Css or any thing along those lines. I know basic HTML and thats about it, so if anyone out that can help, please do so.

Thank you in advance

ddadmin
03-03-2005, 09:30 PM
Well, you can use a function like the below:


function loadiframes(){
document.getElementById("iframe1").src="http://google.com"
document.getElementById("iframe2").src="http://cnn.com"
document.getElementById("iframe3").src="http://msnbc.com"
}

where "iframe1", "iframe2" etc are the ID are the iframes in question. The above function when executed will load the various URLs into the iframes:


<a href="javascript:loadiframes()">Click here</a>

JustSumNJguy
03-03-2005, 10:06 PM
Well thats my point. I know nothing about java. I don't know where to put any of that. Does it go in the header? The body? Do I have to make a java script for that?

he 2nd part is easy as to where to put it, That actually goes before the text I want linked, but what about the rest?

ddadmin
03-03-2005, 10:08 PM
Simply wrap the first part (the function) inside the <script> tag, for example:

<script>
"
"
</script>

and put it in the HEAD section of your page.

JustSumNJguy
03-03-2005, 10:13 PM
Ok, but now comes a stupid question.

I see how this code works, but how do I set it for more then 1 link? Like there are over 15 songs (links), Each song will have 1 page for lyrics and another page for the actual music. Do I use the <script> code for each?

JustSumNJguy
03-03-2005, 10:25 PM
OK, I have this in my head

<head>
<script>
function loadiframes(){
document.getElementById("main").src="BreakingDown.html"
document.getElementById("main3").src="Play.html"
}
</script>


And this is the done on the link

<a href="javascript:loadiframes()">Breaking Down</a> <br />

When open the page up in internet explore, and click the link it says this

Error On Page

In the status bar.

what did I do wrong?

jorgeivan
08-02-2005, 05:36 AM
OK, I have this in my head

<head>
<script>
function loadiframes(){
document.getElementById("main").src="BreakingDown.html"
document.getElementById("main3").src="Play.html"
}
</script>


And this is the done on the link

<a href="javascript:loadiframes()">Breaking Down</a> <br />

When open the page up in internet explore, and click the link it says this

Error On Page

In the status bar.

what did I do wrong?

I think this functions are great. But I need one more thing for it to work perfectly in my site.

I have a form inside an iframe (iframe1), that when submitted, it validates a username and password. Besides, there is another iframe (iframe2) displaying "page1.php".

Now, what I need is that if the user and password are correct, iframe2 should change to "page2.php".

Hope you can help me. Thanks!