Web Analytics Made Easy -
StatCounter Navigation menu open new page in iframe - CodingForum

Announcement

Collapse
No announcement yet.

Navigation menu open new page in iframe

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Navigation menu open new page in iframe

    Ok, I have my site set up to use a javascript navigational menu but I want the links in the nav menu for most pages save for the links to open in the iframe on the main page. I am sure there must be a way to get this menu to load the new page into the iframe instead of just going to that page.

    The javascript is too long to post unfortunately. If someone could tell me either what to add and where in order to tell it to load into the iframe or point me in the direction of another nav thing set up to do this it would be greatly appreciated.
    Once I thought I was wrong but I was mistaken.

  • #2
    dont know how your menu links but best if it called a js function to make the decisions

    linking to top or iframe is not a problem

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    </head>
    
    <body>
    <span onclick="document.getElementById('fred').src='http://www.vicsjavascripts.org.uk';" >Link1</span><br>
    <span onclick="window.top.location='http://www.vicsjavascripts.org.uk';" >Link2</span><br>
    
    <iframe id="fred" src="http://js-examples.com" width="400" height="100" frameborder="0"></iframe>
    </body>
    
    </html>
    can only guess the the menu links to a url by assigning the field with a url
    use a js function call in place of the url

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    function js(x,url){
      if (x=='top'){
       window.top.location='http://www.vicsjavascripts.org.uk';
      }
      if (x=='iframe'){
       document.getElementById('fred').src='http://www.vicsjavascripts.org.uk';
      }
    }
    //-->
    </script></head>
    
    <body>
    
    <iframe id="fred" src="http://js-examples.com" width="400" height="100" frameborder="0"></iframe><br>
    <br>
    <a href="javascript:js('top','http://www.vicsjavascripts.org.uk')" >link 1</a>
    <br>
    <a href="javascript:js('iframe','http://www.vicsjavascripts.org.uk')" >link 2</a>
    
    </body>
    </html>
    Last edited by vwphillips; Aug 2, 2005, 02:35 PM.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

    Comment


    • #3
      Hrm, the script allows me to do this in the config.

      javascript:top.document.location.href='Link.htm'

      Could I not replace that with:

      document.getElementById('iframeidname').src='http://www.thesitewiththetargetpage.org';



      Then it would simply open the clicked link in the menu into the named iframe correct?
      Once I thought I was wrong but I was mistaken.

      Comment


      • #4
        if it is link specific

        try it

        make sure the iframe has an id
        Vic

        God Loves You and will never love you less.

        http://www.vicsjavascripts.org/Home.htm

        If my post has been useful please donate to http://www.operationsmile.org.uk/

        Comment


        • #5
          Yeah, I'll give it a shot because it says in the script that I can call any javascript there. I found a workaround anyway but it'd be groovy to have this working right.
          Once I thought I was wrong but I was mistaken.

          Comment


          • #6
            You can also do this:
            Code:
            <a href="page.htm" [B]target="[I]nameOfIframe[/I]"[/B]>This link goes to the iframe</a>
            <a href="page2.htm" [B]target="_top"[/B]>This link goes to the outermost window</a>
            Glenn
            vBulletin Mods That Rock!

            Comment

            Working...
            X