🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.javascript
2 messages
2 total messages Started by Erik van Roekel Mon, 29 May 2000 00:00
Help needed with script for loading right page
#60
Author: Erik van Roekel
Date: Mon, 29 May 2000 00:00
30 lines
1913 bytes

I'm using Netobjects Fusion (NOF) for developing my site and I'm using
frames. For every page NOF generates 3 files a name.html (the
mainpage) and two pages which defines the frames used called
body_name.html and header_name.html. (name could be any name).

The pages which start with body_ or header_ shouldn't be loaded
individually. So I'm looking for a javascript which redirect the user
if necessary.

If a user loads a page and the name of that page starts with "body_"
or "header_" the user has to be redirect to the name used without
"body_" or "header_" in this case index.html. 

One script for all pages independent if the right page is named
index.html or info.htm

Procedure:
1. Check if the page starts with "header_" if so go to step 4
2. Check if the page starts with "body_" if so go to step 4
3. Quit
4. Load the right page by deleting "header_" or "body_" in the URL
used and
loading the new corrected url.

Any Javascript expert who can solve this case ?

Regards,
Erik
Re: Help needed with script for loading right page
#61
Author: T. Postel
Date: Mon, 29 May 2000 00:00
73 lines
3144 bytes
In article <3932a6c2.2214143@news.arnhem.chello.nl>, e.vroekel@chello.nl 
(Erik van Roekel) wrote:
>
>
>I'm using Netobjects Fusion (NOF) for developing my site and I'm using
>frames. For every page NOF generates 3 files a name.html (the
>mainpage) and two pages which defines the frames used called
>body_name.html and header_name.html. (name could be any name).
>
>The pages which start with body_ or header_ shouldn't be loaded
>individually. So I'm looking for a javascript which redirect the user
>if necessary.
>
>If a user loads a page and the name of that page starts with "body_"
>or "header_" the user has to be redirect to the name used without
>"body_" or "header_" in this case index.html. 
>
>One script for all pages independent if the right page is named
>index.html or info.htm
>
>Procedure:
>1. Check if the page starts with "header_" if so go to step 4
>2. Check if the page starts with "body_" if so go to step 4
>3. Quit
>4. Load the right page by deleting "header_" or "body_" in the URL
>used and
>loading the new corrected url.
>
>Any Javascript expert who can solve this case ?
>
>Regards,
>Erik
>
If I understand what you want, I think you could use something like 
this. This is based on some working script I have used, but I didn't 
test it.  The frame page can check to see if it has the correct parent. 
If you put this in the <head> section of each frame page 
("body_page.html") it will load the correct frameset:

<script language="javascript">
if(top == self) {
  s = self.location.href
  i = s.indexOf("body_") 
  if (i)=> 0) {
    temp = s.substr(i+5) + "?" + s.substr(i)
    }  
  i = s.indexOf("header_")
  if (i)=> 0) {
    temp = s.substr(i+7) + "?" + s.substr(i)
    } 
document.location.href = temp
}
</script>

If you put this in the frameset page and call it with a <body 
onLoad="loadPage()...> it will load the correct page in the header or 
body:

<script language="javascript">
function loadPage() {
var temp = document.location.href.split("?")
  if ((temp[1].indexOf("header_") { parent.header.location.href = 
temp[1] }
  if ((temp[1].indexOf("body_") { parent.body.location.href = temp[1] }
}
</script>

good luck.


-- 
While my e-mail address is not munged,     | T.Postel@ieee.org
I probably won't read anything sent there. |
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads