Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

forced frame problem: named anchors, and history

Status
Not open for further replies.

retrositelover

Programmer
Oct 20, 2004
35
0
0
Hi,

on my homepage, I use a little javascript to load pages in a frameset if on top. there are two problems: the back-button needs to be clicked more than one time if the visitors want to leave, and named anchors don't work, so the page loads in the frame, but doesn't jump to the texts automatically

the frameset...
Code:
startURL=parent.document.URL
internalURL=startURL.substring(startURL.indexOf('?')+1,startURL.length) 
document.write('<FRAMESET COLS="38%,62%" FRAMESPACING="1" FRAMEBORDER="0" BORDER="1" BORDERCOLOR="white"><FRAME NAME="left0" ID="left0" SRC="navigation.html"><FRAME NAME="right0" ID="right0" SRC=" ' + internalURL + ' "><NOFRAMES>&lt;<A HREF="navigation.html">sitemap<\/A>&gt;<\/NOFRAMES><\/FRAMESET>')

and in the page that has to load in frames...
Code:
internalpage=document.URL
if(top.location==self.location)top.location.href="frameset.html?"+internalpage

demo

thanks in advance for any hint :) + kind regards
Joerg
 
as to the history problem: I guess there's no other way than to accept the named anchor will force 2 history entries. of course, despite the code above, this is far more elegant:

Code:
top.location.replace("frameset.html?" + internalpage,true);

leaves the second problem:

the page will continuously reload due to the onload event handler if the link contained no anchor

demo:
with jump target
where it's missing (reload)

can someone help me modifying this script so that it recognizes if the referring link has no named anchor inside it, which would prevent further reloads? ->

Code:
function goToLine() {
var ar_url=parent.location.href.split('?');
if(ar_url[1]) {
document.location=(ar_url[1]);
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top