2 Links, One Click

LordHelmut
08-19-2002, 02:34 PM
Im trying to make it so when you click on a image (button) in html, it loads two pages. See, my page is in 3 parts with tables, one is a nav menu, the other two parts are Iframe's. When a button in the nav bar is clicked it has to load a page in one iframe and one in the other iframe. Here is the javascript I got...


<script language="javscript">
function loadBothFrames(firstlink,secondlink)
{
iframe1.location=firstlink;
iframe2.location=secondlink;
return 0;
}
</script>

....as we venture further down the page....

<a href="java script:loadBothFrames('hey.html','ohhi.html');">your image</a>


but I need to figure out how to send links to it. So like when one button is clicked, one iframe is loaded with lets say like this...

Button is clicked in navbar called HOME. In the submenu iframe it loads in submenu-home.php and in the main iframe it loads in home.php then for lets say the downloads button, it loads in submenu-downloads.php and downloads.php and so on. How would I recycle that javascript to do it for each button.

rich2kchan
08-20-2002, 12:19 AM
I dont exactly understand wat u mean, but i think, to "recycle" or reuse the function u listed above:


<script language="javscript">
function loadBothFrames(firstlink,secondlink)
{
iframe1.location=firstlink;
iframe2.location=secondlink;
// return 0; -- Dunt think u need this
}
</script>


Why dont u just change the 2 parameters in the function:


<a href="javascript:loadBothFrame('sub1.html','main1.html')">image1</a>
<a href="javascript:loadBothFrame('sub2.html','main2.html')">image2</a>
<a href="javascript:loadBothFrame('sub3.html','main3.html')">image3</a>

ChiefRedBull
08-20-2002, 04:18 AM
Also, make sure you've identified your IFRAMEs -
<IFRAME ID="IFRAME_MAIN" SRC="blah.html" etc..>
<IFRAME ID="IFRAME_SUB" SRC="blah.html" etc..>
Then the script would be:

<script language="javscript">
function loadBothFrames(firstlink,secondlink)
{
document.getElementById("IFRAME_MAIN").location.href=firstlink;
document.getElementById("IFRAME_SUB").location.href=secondlink;
}
</script>

LordHelmut
08-20-2002, 05:35 PM
I tried everyone you guys said and it just didnt work. I put the javascript in, changed iframe1 to Menu and iframe2 to Main and then used the call to make it so when the home button is clicked (the center one) it loads those two pages in. It did not work :( I have attached it to see if you guys can make it work :(

ChiefRedBull
08-21-2002, 04:34 AM
I can't see any attempts at scripting in these files... and why are they PHP extension - there's no PHP in them...?

I couldn't get my browser to recognise the IFRAMEs via their ID or NAME attributes, but this worked ok:

<script language="javascript">
function loadBothFrames(main,sub)
{
var w=document.frames[0];
w.location=sub;
var w=document.frames[1];
w.location=main;
}
</script>

LordHelmut
08-21-2002, 02:29 PM
Well, when I tried it, it didnt work so I just reloaded the page without my additions so it would be ok. I just tried again and its still doing the same thing. I have attached the file for the index.php I tried to add the code to. It has the javascript up top, and then in the nav part I changed the home button to the javascript link...but when you click home, instead of loading pages in, it just loads some error page. :(

I have them as php because I plan to add php stuff to them soon.

LordHelmut
08-21-2002, 07:37 PM
Alright, here is my version with all the script and link stuff added. I just dont see any difference between what you posted and this and yet it doesnt work :(

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum