Click to See Complete Forum and Search --> : Preserving FRAMESET when opening a single FRAME (page)
Hey peeps!
My site is frame-based. When a guest bookmarks/links one of my pages and later re-visits it, he/she no longer sees original FRAMESET, but instead, a single page.
How can I force entire FRAMESET to appear; in other words, can browser open a requested page and then load a missing frame page?
I tried using this code in HEAD:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (window == top) top.location.href = "frameset.html";
// End -->
</script>
It kinda works, but opens original FRAMESET with originally coded pages, not linked/bookmarked.
Thank you for any idea!
Nevermore
02-16-2003, 03:46 PM
Try this (im not sure if it works, but im sure u can fix it if it doesnt):
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (window == top)
{
current = top.location.href;
top.location.href = "frameset.html";
frame_name.location.href = current;
// End -->
</script>
If the pages open in different combinations, I dont think there is any way to get the other frames though.
gizmo
05-18-2003, 04:06 AM
This is just what I have been trying to cahieve for months so I have put this script in <head>
function loadMain() {
var url, str = top.location.seach.substr(1);
if (str.length > 0) {
url = str.substring(str.lastIndexOf("/")+1));
} else {
url = "home.html"; //choose default content
}
top.frames.main.location.href = url; // put URL in "main"
}
and the first FRAMESET reads:
<FRAMESET onLoad="loadMain" rows="75,*">
But I get
Error: expected ';' for the 'if' line (or thereabouts)
Error: 'loadMain' is undefined for the '<FRAMESET' line
but I fail to see what's wrong.
:confused:
gizmo
05-18-2003, 09:44 AM
Thanks for spotting that, but now my second error has changed to 'Object expected'.
gizmo
05-18-2003, 12:55 PM
And to think I tested the url code and did a 'cut & paste' to avoid errors! That corrected, I now get "Error: 'top.location.search' is null or not an object"
I surmise that it is not null, because IE shows things correctly in the address bar, so now this is becoming a challenge.
gizmo
05-18-2003, 03:02 PM
Eureka, got it. Mind you it does help if 'search' is spelt correctly:D
gizmo
05-20-2003, 07:18 AM
Now for the icing on the cake. Since each 'content' page loaded into the 'main' frame has the same script, can this script be given a name and put in a common folder and called from the appropriate pages (like a subroutine)? I have seen this done, but in this specific case I think it may not work because of the need to identify the calling page.
gizmo
05-20-2003, 08:52 AM
It's the line 'top.frames.main.location.href = url;' which I have reservations about moving to another folder/subdirectory. Would the script still recognise the frameset?
gizmo
05-21-2003, 11:53 AM
Having done that successfully {your help is much appreciated :-)}, I noticed during testing that if I select a page, the framset appears with that page correctly in place. Now, if I use the navigation frame to select a different page (which also correctly appears), but then select 'Refresh', since the address bar (IE5) still contains something like "index.html?url=content.html" then 'content.html' gets reloaded instead. My creativity has failed on this too. Although not essential, Is there a way to remedy this as it is obviously a feature rather than a bug? :D