Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England, Hythe
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    linking to an anchor inside a frameset

    how can i make a link that will link to an anchor inside a frameset i.e i have my frameset bobsframeset.htm and that holds two pages bobtop.htm and bobsbottom.htm i need to link to a anchor called "two" in bobsbottom.htm but i still want bobstop.htm

    so <a href="bobsbottom.htm#two">two</a> wont do cos i need bobstop.htm at the top of the page

    so if you could do something like

    <a href="bobsframset#anchor"two"inbobsbottom.htm">two</a> but that is just crap code but some like that??

    thanks for the help

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:
    <A HREF="#" onClick="parent.anchorb.location='anchorpage.html#firstone'">First Anchor</A>

    "anchorb" being the name of the frame and anchorpage.html is the name of the document in that frame.

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Which page is the link in Top or Bottom?

  • #4
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,059
    Thanks
    0
    Thanked 13 Times in 13 Posts
    The only way I have found that this type of thing will work is by using a little bit of Javascript... (this thing just about killed me two years ago when I racked my brain in figureing it all out)... The reason why it will not work from a standard link is because a standard link is erased once the browser loads the frameset index, in this case bobsframeset.htm... bobsframeset does not hold the anchor, instead bobsframeset holds the pages that will appear within the frameset, bobsbottom (this one is where the anchor resides) and bobstop... So what you have to do is use javascript to create the frameset page and plug in the link information (target page and target anchor) after the frameset loads...

    Basically your link would look like:

    Code:
    Test this <A HREF="bobsframeset2.htm?newLink=bobsbottom.htm&newAnchor=two">two</A>
    and your bobsframeset2.htm page would look like such:

    Code:
    <HTML>
    <HEAD>
    </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    function getParams() {
    var idx = document.URL.indexOf('?');
    var params = new Array();
    if (idx != -1) {
    var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
    for (var i=0; i<pairs.length; i++) {
    nameVal = pairs[i].split('=');
    params[nameVal[0]] = nameVal[1];
       }
    }
    return params;
    }
    params = getParams();
    </SCRIPT>
    </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    newLink = unescape(params["newLink"]);
    newAnchor = unescape(params["newAnchor"]);
    
    document.write("<FRAMESET ROWS=14%,* FRAMEBORDER=NO FRAMESPACING=0>");
    document.write("<FRAME SCROLLING=NO NORESIZE FRAMEBORDER=NO SRC=bobstop.htm NAME=top>");
    document.write("<FRAME SCROLLING=AUTO FRAMEBORDER=NO SRC=" + newLink + "#" + newAnchor + " NAME=main>");
    document.write("</FRAMESET>");
    </SCRIPT>
    <NOFRAMES>
    <BODY BGCOLOR="#000000" TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000">
    </BODY>
    </NOFRAMES>
    </HTML>
    So what you are doing is using javascript to build the frameset and use the search string to fill in the link/anchor information as the frameset is built so that the referenced page opens to that anchor...

    HTH,

    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #5
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Try




    If the link to the anchor is in "bobsbottom.htm" use:

    <a href="bobsbottom.htm#two">two</a>

    If the link to the anchor is in "bobstop.htm" use:

    <a href="#null" onclick="parent.framename.document.location='bobsbottom.htm#two'">two</a>




    where anchor =

    <a name="two"></a>


    framename = name of frame containing bobsbottom.htm

  • #6
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,059
    Thanks
    0
    Thanked 13 Times in 13 Posts
    you guys are assuming he is linking from within the frame... It sounds as if he wants another page to link to an anchor within a frameset...

    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Next time you post - particularly if it involves a frameset - give as many details as you can, specifically the HTML involved. Can't expect people to help you navigate without a map.

    That said, this might help:

    http://www.htmltutorials.net/html_tu...es_target.html

    The <a href="..." TARGET="frame_name"> attribute determines which frame a link opens in.

  • #8
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Linking from an external window to an anchor in a frameset would still be

    <a href="#null" onclick="parent.framename.location='bobsbottom.htm#two'">two</a>

  • #9
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I started using this script on my site, the only problem is that google and yahoo already link to the frameset file but without parameters so the page generate 2 frames but both with 404 errors. Can anyone think of a way to get something to come up without have parameters in the link?

    Heres what google links to:
    http://www.zipstoys.com/database/dol...ortedframe.htm
    Which doesn't work

    Heres what my main page links to:
    http://www.zipstoys.com/database/dol...heelbarrow.htm

    Thanks

  • #10
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    re: Linking to an anchor inside a frameset

    Sorry if I ask too much, or for being dummy.. I don't know much about Javascript and need to do just the same as below, but my site has 4 frames (top, left, bottom and mainframe, where the anchors are located.
    Seems like something needs to be added to your code. Any chance you can help me ?
    Thanks a lot in advance..


    Quote Originally Posted by sage45 View Post
    The only way I have found that this type of thing will work is by using a little bit of Javascript... (this thing just about killed me two years ago when I racked my brain in figureing it all out)... The reason why it will not work from a standard link is because a standard link is erased once the browser loads the frameset index, in this case bobsframeset.htm... bobsframeset does not hold the anchor, instead bobsframeset holds the pages that will appear within the frameset, bobsbottom (this one is where the anchor resides) and bobstop... So what you have to do is use javascript to create the frameset page and plug in the link information (target page and target anchor) after the frameset loads...

    Basically your link would look like:

    Code:
    Test this <A HREF="bobsframeset2.htm?newLink=bobsbottom.htm&newAnchor=two">two</A>
    and your bobsframeset2.htm page would look like such:

    Code:
    <HTML>
    <HEAD>
    </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    function getParams() {
    var idx = document.URL.indexOf('?');
    var params = new Array();
    if (idx != -1) {
    var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
    for (var i=0; i<pairs.length; i++) {
    nameVal = pairs[i].split('=');
    params[nameVal[0]] = nameVal[1];
       }
    }
    return params;
    }
    params = getParams();
    </SCRIPT>
    </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    newLink = unescape(params["newLink"]);
    newAnchor = unescape(params["newAnchor"]);
    
    document.write("<FRAMESET ROWS=14%,* FRAMEBORDER=NO FRAMESPACING=0>");
    document.write("<FRAME SCROLLING=NO NORESIZE FRAMEBORDER=NO SRC=bobstop.htm NAME=top>");
    document.write("<FRAME SCROLLING=AUTO FRAMEBORDER=NO SRC=" + newLink + "#" + newAnchor + " NAME=main>");
    document.write("</FRAMESET>");
    </SCRIPT>
    <NOFRAMES>
    <BODY BGCOLOR="#000000" TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000">
    </BODY>
    </NOFRAMES>
    </HTML>
    So what you are doing is using javascript to build the frameset and use the search string to fill in the link/anchor information as the frameset is built so that the referenced page opens to that anchor...

    HTH,

    -sage-


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •