...

View Full Version : linking to an anchor inside a frameset



Bluemonkey
10-09-2002, 11:48 AM
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 :D

requestcode
10-09-2002, 02:43 PM
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.

Mr J
10-09-2002, 02:48 PM
Which page is the link in Top or Bottom?

sage45
10-11-2002, 09:45 PM
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:



Test this <A HREF="bobsframeset2.htm?newLink=bobsbottom.htm&newAnchor=two">two</A>


and your bobsframeset2.htm page would look like such:



<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... :cool:

HTH,

-sage-

Mr J
10-11-2002, 10:33 PM
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

sage45
10-12-2002, 01:29 AM
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-

adios
10-12-2002, 02:12 AM
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_tutorial/frames_target.html

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

Mr J
10-12-2002, 01:02 PM
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>

trevras
08-11-2006, 05:28 PM
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/dolls%20-%20assorted/assortedframe.htm
Which doesn't work

Heres what my main page links to:
http://www.zipstoys.com/database/dolls%20-%20assorted/assortedframe.htm?newLink=assortedmaster.htm&newAnchor=aprile&newPic=aprile-wheelbarrow.htm

Thanks

fiorenza
02-26-2009, 08:08 PM
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..



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:



Test this <A HREF="bobsframeset2.htm?newLink=bobsbottom.htm&newAnchor=two">two</A>


and your bobsframeset2.htm page would look like such:



<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... :cool:

HTH,

-sage-



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum