PDA

View Full Version : frame saver script (a la joh6nn)


Gordo
12-31-2002, 10:24 PM
I'm using joh6nn's code from this archived post (http://www.codingforums.com/ubb/Forum4/HTML/009362.html). So you don't have to click the link, joh6nn says the following:this first part goes in the page, where you create your frames. ie, frames.htm
<SCRIPT>
function frame_saver()
{
if (self.location.search)
{
self.FRAMENAME.location = "http://www.DOMAIN.com" + self.location.search.slice(1);
}
}

self.onload = frame_saver;
</SCRIPT>

this second bit goes in any frames that don't change, like frames you use for navigation.

<SCRIPT>
if (self == top) {self.location = "http://www.DOMAIN.com/frames.htm"; }
</SCRIPT>


this last part goes in all of the pages that are in the main frame; the ones that you want to be able to bookmark.

<SCRIPT>
if (self == top)
{
var url = self.location.pathname;
self.location = "http://www.DOMAIN.com/frames.html?" + url;
}
</SCRIPT>I'm missing something because it's not working quite right. If I had to guess, I'd say I'm incorrectly replacing the FRAMENAME in the code that is placed on the framed page (the first bit of code). Instead of loading the targetted page in the proper frame, it simply loads the default home page.

Upon typing in http://www.jimthomasstudio.com/figurative.htm, I get http://www.jimthomasstudio.com/index.html?/figurative.htm. I'm thinking that forward slash is killing the figurative.htm portion.

Any help?

Mr J
01-02-2003, 08:12 PM
In the frameset page:

<SCRIPT LANGUAGE="JavaScript">
<!--
function LoadFrame(){
if (self.location.search){
parent.framename.location = location.search.substring(1,location.search.length);
}
}
onload = LoadFrame
// -->
</SCRIPT>

Where framename is the frame that the page is loaded into

The following is place in the head section of the page you want loaded into framename.

<SCRIPT LANGUAGE="JavaScript">
<!--
if (self == top){
var url = self.location;
self.location = "frameset.htm?" + url;
}
// -->
</SCRIPT>

Gordo
01-03-2003, 02:57 AM
Thanks for the reply.

It's interesting. Your solution works, but only after completely loading all the default frame pages. On dial-up, this takes some time. But, it does eventually kick over to the targeted page.

Any way to get this to auto-jump, and avoid having to download the initial framed pages!?

Of course, now that I look at it, joh6nn's original code also works, but with the same delay. I just wasn't waiting long enough for it to jump to the correct target page.

Mr J
01-03-2003, 06:25 PM
I do have another method but the scripts are a little more indepth.

If you wish to take a look see.


www.huntingground.freeserve.co.uk/webplus/frames/loader2.htm



This is the one I use on my site

Gordo
01-03-2003, 10:23 PM
Perfect!!!

That's much better ... no loading of the default page ... goes straight to the intended target page (framed)!

Let's just hope my users have JavaScript enabled. If they don't...too bad for them!

Thanks!!! :thumbsup: