Click to See Complete Forum and Search --> : Trouble with the frames.history.go function
DoLordBoy
03-11-2003, 12:21 PM
Alright, I've been trying to do this for a while now...
for my site, I have frames. However, people often get linked to individual pages that would normally be inside a frameset, and I want them to be able to navigate the site from there. So I make it link to a page I named "addframes.html", the hyperlink text saying "don't see frames? click here". It links to a frameset, with the right frame's name is "back.html"
Here comes the javascript part. On back.html, I have
<body onLoad="frame.history.go(-1,_self)">
For some reason, it either won't work half the time, or the other half it goes back, not keepoing either frame, as if I'd given it a target=_top function.
Any simpler way to do this?
DoLordBoy
03-11-2003, 12:51 PM
Forgot to add, I know the only other way I can think of doing this would be by making a new frameset for every individual page, but I"m going to try avoiding doubling the space on the site if possible
DaveSW
03-11-2003, 12:58 PM
Someone else posted this code a while back on the site. Haven't tried it myself, but it would seem to solve your problem if it works
Display all frames from search engine
I put this in the sub-document :-
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
if (window.location.href == top.location.href)
{
if (window.location.replace)
// best solution, but may not be supported
window.location.replace('index.htm?' + window.location.href);
else
// causes problems with back button, but works
window.location.href = 'index.htm?' + window.location.href;
}
//-->
</SCRIPT>
... and this in the frameset document :-
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
var first = true;
// Function to see if HTML document has been passed in as parameter
// ("search string"), and if so to put in main frame
function initframe()
{
if (first)
{
first = false;
if (window.location.search != '')
window.frames[2].location = window.location.search.substr(1);
}
}
//-->
</SCRIPT>
... then put this where the frame is defined in the frameset document :-
<FRAME SRC="Home.htm" NAME="Main" ONLOAD="initframe()">
Dunno if this helps
Dave
DoLordBoy
03-11-2003, 12:59 PM
thanks, I'll try that:D
DoLordBoy
03-11-2003, 01:22 PM
Alright, I must admit, I use mostly html and am horrible at javascript.
If the page I"m using this on first is called contact.html and the frameset I made for adding frames is addframes.html, then how should I go about making this?
DaveSW
03-11-2003, 01:57 PM
I have absolutely no idea... maybe someone else can help you - i'm in about the same position as you are - my javascript is the cut and paste variety!
DoLordBoy
03-15-2003, 01:09 PM
Alright, I've thought of doing this:
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
if (self==parent)
{
document.write("<frameset cols=15%,85%><frame src="navbar.html" noresize scrolling=no name=rightside><frame src="contact.html" name=rightside>");
}
</SCRIPT>
,changing the bold URL depending on what page the link is at.
It doesn't seem to be working though. Anyone know why?