View Full Version : iframe questions (LINK)
Hello,
I have a questions about links and iframes. I am trying to create a link that goes to for example http://a.com which uses iframes. Depending on the link, I would like to have a different page show up in the iframe of http://a.com. How would I go about doing this?
For example:
"a.com link 1" goes to a.com with 1.html loaded into the iframe.
"a.com link 2" goes to a.com with 2.html loaded into the iframe.
and so on. Any information would be greatly apreciated! Thanks!
Kei
Juparis
08-20-2004, 07:24 PM
As far as I know, there's no way to do what you're trying--or at least not with regular html (I think). I could be wrong, but you might need to use JavaScript and some type of form to get the page loaded in the iframe.
thanks juparis. If anyone can direct me to any sample codes HTML or JS I would appreciate it. My searches are not going too well:( .
Thanks,
Kei
easilyi
08-20-2004, 09:15 PM
easy enough to do with php...assuming you add the page to that link, for example a.com/a.php?pass=whatever
so, if that works for you, then the following code will do the job.
code for test.html
<html>
<body>
<a href="a.php?iframe=1">link to a.php with 1.html in iframe</a><br/>
<a href="a.php?iframe=2">link to a.php with 2.html in iframe</a>
</body>
</html>
code for a.php
<html>
<body>
Whatever content is always in a.php<br />
Then the dynamic content in the iframe below.<br />
<?php
if ($iframe == 1)
{
printf("<iframe src=\"1.html\"></iframe>");
}
else
{
printf("<iframe src=\"2.html\"></iframe>");
}
?>
</body>
</html>
and then just create 1.html and 2.html with whatever content you want.
Thanks easilyi.
Is there any way I can do it in JavaScript?
Kei
easilyi
08-21-2004, 12:18 AM
sorry, don't know much JavaScript, maybe somebody else will give an example.
and not that it matters now, but that php code could be simplified even more. i just added it quickly to try and help...i feel like i rarely give back to forums although i get a lot from them...
anyway, good luck!
no problem. I would use the php code but I can't change the current a.html to a.php for internal reasons. thanks though!
anyone else have any ideas?
thanks!
iFrameHelp
12-22-2004, 03:12 PM
I got 3 iFrames on the same page, how do I tell it what iFrame to change?
Juparis
12-23-2004, 03:49 PM
Whichever iframe would be the one you want to load various pages into would be where you insert the PHP coding. You can keep the rest of your coding (including your other iframes) just the way they are.
If you're still confused, could you show us some coding and explain a bit more?
worthers20
12-24-2004, 02:50 AM
Can't you just name the IFRAMES and use target="youriframename" on your links?
Juparis
12-24-2004, 03:03 PM
No, the topic in discussion is using links from an outside site (or just a different page) and having a different page automatically load into the iframe depending on the link. Since the link is on a different page, you can't specefy a target and expect it to work.
CoonDesign
12-24-2004, 03:47 PM
ya, to direct to differnt iframe just name the iframes:
<iframe src="" name="frame1"></iframe>
<iframe src="" name="frame2"></iframe>
<iframe src="" name="frame3"></iframe>
then link to them:
<a href="www.yahoo.com" target="frame1">Yahoo</a>
<a href="www.msn.com" target="frame2">MSN</a>
<a href="www.google.com" target="frame3">Google</a>
-RacCoon
Juparis
12-24-2004, 11:50 PM
That would work if you want the pages to appear in the iframes of your existing iframes. This thread is discussing opening a new page with a different page loaded into the iframe by default. I just want to make sure that's clear to everyone. ;)
iFrameHelp
12-26-2004, 01:57 PM
NVM I got it to work.
iFrameHelp
12-26-2004, 01:58 PM
double posted...
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.