forcing a site into a frame

They have: 74 posts

Joined: Sep 2000

HI i want to know if there is a way i can set my site up so that any time that a page is visited without its frame is automatically forced into a frameset:
ex(my first time in ascii art):

Lats say someone visits a page on my site directly =(they view a page that is supposed to be viewed in a frameset) whatever.htm:

_____________________
| |
| |
| |
| |
|whatever.htm |
| |
| |
| |
|_____________________|

How do i make sure that if a visitor views a page like above it is automatically forced in a frame like below:

----------------------------------------
navigation |
bar |
|
|
|
|
| whatever.htm
|
|
|
|
-------------------------------------------

i hope you undertand my question and I hope you can answer it. thanks in advance.
PS: tell me what you think about my ascii art. LOL, i've never tried it before.

hehe

They have: 61 posts

Joined: Aug 2000

is javascript to tell if it is in frames, if it is then leave it alone, if it isn't then document write the frames. Very simple. Make the "main" frame the URL to the current page....

hope this makes since, i think that javascript source may have something pre-written, i'm short on time, or i would do it for ye.

alex

[=1]Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.[/=1]

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

http://www.irt.org has tutorials and explanations on JavaScript and Frames and how to do this.

Yes, it's possible, but depending on what you want to do, it can be complex. If it's just testing for a frameset, it's quite simple, but I will defer to them, as they explain it so well.

Smiling Suzanne

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

this will make every page go the homepage thingy...

// your_frames.js file
// you can use the link to include this in every page

if (top.location == self.location) {
  top.location = "frames.html"
}
'

this will force every page into frames without sending them to the homepage. it will be different in every page, so you can't link it.

<HTML>
&lt;script LANGUAGE=JAVASCRIPT&gt;
<!--
<strong>// your_framed.html</strong>
linkURL = "<strong>home.html</strong>" //default page
if (parent.document.URL) {
callingURL = parent.document.URL
if (callingURL.indexOf('?') != -1) {
linkURL = callingURL.substring(callingURL.indexOf('?')+1,callingURL.length)
}
}

document.writeln('<FRAMESET COLS="30%,70%">')
document.writeln('<FRAME SRC="your_nav_bar.html" NAME="left">')
document.writeln('<FRAME SRC="' + linkURL + '" NAME="content">')
document.writeln('<\/FRAMESET>')

// -->
&lt;/script&gt;
</HTML>


<HTML>
&lt;script LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT"&gt;
<!--
<strong>// some_page.html</strong>
if (top.location == self.location) {
  top.location.href = "<strong>your_framed.html</strong>?<strong>some_page.html</strong>"
}
// -->
&lt;/script&gt;
<BODY BGCOLOR=WHITE>
blah blah blah
</BODY>
</HTML>
'

You *should* be able to copy paste and just edit the bold stuff.

Good Luck,

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 74 posts

Joined: Sep 2000

Do i put in the body, the head tag. on every page i want forced, or just on the original frame set page? please be more specific on this i have no clue where to put it. thanks for your help?

hehe

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

put that on every page that you want forced into frames right here

They have: 74 posts

Joined: Sep 2000

When I tried the code you gave me, one or more of the following things happened:
1. I got a message saying THIS PROGRAM HAS PERFORMED AN ILLEGAL OPERATION AND WILL BE SHUT DOWN
2. i was just redirected to the INDEX page(with the original frameset)
3. it ran correctly but the MAIN CONTENT window just stayed blank
4. I got mad
5. I turned off my computer
Please help.

hehe

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I coppied and pasted this code from here:
http://chalcedony.com/javascript/scripts/script04.03.html
the homepage to the site is here:
http://chalcedony.com/javascript

I don't know....

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 74 posts

Joined: Sep 2000

No wonder, I have that same book/code the reason why i posted here is becuase i couldn't get it to work.
oh well...

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

so your saying it's flawed in the book??
I hate it when that happens! I wish people proofed their books more thuroughly.

They have: 74 posts

Joined: Sep 2000

never mind, a few minutes after i read your post i remembered something the book said about certain scripts not running correctly offline on certain browsers. and when i uploaded your/the book's code to the internet on my site and tried it, it worked.
YEEEEEEEEAAAAAAAAHHHHHHHH!!!!!!!!!!!!!!!

hehe

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

interesting... I never heard that about the offline thing before.

Actually, I don't think that makes sense... JavaScript is client side, so I don't see why that would make a difference.

But hey, if it works, why complain. Right?

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 74 posts

Joined: Sep 2000

the flaw is in the browser not the code the book said that there is some bug that in explorer that it can't handle some javascripts locally

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.