Web help needed: The link

Started by InCreator, Fri 06/10/2006 05:23:12

Previous topic - Next topic

InCreator

I've been learning web design alot lately and come to a weird discovery:
Hyperlink has only one location.

I mean, you have one link, you click, and you one web page opens.
But I need two.

The page i'm working on, has 2 iframes, and I need to give both iframes content when only one link is clicked.

explanation:
One iframe is for "contents" list (a submenu), and another one displays actual content.
So, from the main menu,
* clicking on (for example) "games" should display html file (with clickable game list) in Frame 1
* and games page welcome in Frame 2.

HTML supports only 1 location to each link.
How to work around?



Evil

Make the two sections one page. So the link is opening another page, which has the two pages on it.

Peder 🚀

There is also a way of doing this with javascript.

As I done it before, though I do not remember how now :-\
I will try and look for it and edit my post.

SSH

Use divs instead of evil iframes
12

Klaus

For your current setup you probably need to use Javascript as Peder suggested.
I guess this is what you're looking for:

Code: ags

<html>
  <head>
    <script language="JavaScript" type="text/javascript">
<!--
      function newcont(suburl, conturl)
      {
        document.getElementById("submenu").src=suburl;
        document.getElementById("content").src=conturl;
      }
//-->
      </script>
  </head>
  <body>
    <a href="javascript:newcont('subA.htm','contA.htm');">Change to A</a>
    <a href="javascript:newcont('subB.htm','contB.htm');">Change to B</a>
    <br />
    <iframe src="default_submenu.htm" id="submenu" name="submenu"></iframe>
    <iframe src="default_content.htm" id="content" name="content"></iframe>
  </body>
</html>


Be aware that Javascript codes (as well as iframes) do not work on all browsers. But for most of your visitors it shouldn't be a problem at all.

Using current techniques you should put it all (menu/submenu/content) in just one page, maybe using AJAX to change the content. But this is another topic and better start it small... Good luck for your site!

InCreator

#5
Thanks, I'll see if it works.
Still, quite weird that iframes can't be used as objects, i mean

iframename.src

kind of variable is set in iframe create only and unchangeable?
I CAN change the content via links. Like, set link's target as iframename. Why can't i do it just via code, without anything clickable?

Also, I can't figure out how to erase iframes once they've set.

It's 2006 and there's lots of web languages. How could such easy thing like multilink be impossible without hardcore javascripting?

This whole thing is really difficult, I'd say - much harder than usual computer programming in any language. There's just a big mess I see...

Anyways, I'll get to work now.

Peder 🚀

I would suggest to learn PHP and use that instead ;D hehe.
Some variables does the trick :P.

But try what Klaus gave you.

Sorry I never got to edit my post with a link, but I was at work at that moment and I had to go out on a job :-\

Good luck.

Peder.

TerranRich

I actually agree with the PHP sentiment. There's nothing like dynamic programming to solve most problems you'll come across.

e.g., clicking on "games" would link to index.php?s=games. In the code of index.php, you'd have the usual header (the top menu), and the two iframes, and some if or switch blocks that would detect which value "s" was set to in the query string and display the appropriate content. It makes web design so much easier and much more organized. :)
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk