Link to home
Start Free TrialLog in
Avatar of mnewnham
mnewnham

asked on

Specifying frame behaviour

How can I force a page, designed to appear in a frame, to always appear in that frame even when the URL is called directly from a browser.
Avatar of mayhew
mayhew

I would use javascript to detect if the page is in a frame.

If it's not, I would redirect the browser to the url that includes the framed version of the page.

Let me know if you need more details.
ASKER CERTIFIED SOLUTION
Avatar of mblase
mblase

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi mblase,

It's considered bad taste in this forum to post somebody else's comment as an answer.

The fact that you supplied code is irrelevent.

Please be more considerate.
Hi mayhew and the others
I am a learner too and always apprechiated the answers which have some code which I can cut, paste & modify. By just telling "I would use javascript to detect if the page is in a frame..." is really no more than pointing mnewnham in a direction he is probably well aware of already... If you feel bad about that mblase beat you with an answer... then do it the same way next time. After all you have answered many questions in the past so you should know that this can and will always happen.

Edi

Try this too mnewnham... it starts my frame page always as a frame even when you enter the menu or logo frame url 1st.  


<html>
<head>
   
<title>Your page title</title>

<SCRIPT LANGUAGE="JavaScript">

<!--Hide script from old browsers
 if (top.location == self.location){
                 top.location.href = "index.htm"
                                            }
// End hiding script from old browser-->

</script>

</head>
>I am a learner too and always apprechiated the answers

You'll notice that I didn't post an answer.  I posted a comment offering more details.

This is a common practice on this forum that (1) saves bandwidth, time and space and (2) allows the questioner to verify that what I'm offering will answer the question.


>If you feel bad about that mblase beat you with an answer... then do it the same way next time.

mblase didn't beat me with an answer.  He just posted the same thing I said as an answer and then added an example.

Ask anyone whose been on this forum for a while and they will tell you that's a pretty rude practice.

I would never do it somebody else.  And I don't appreciate that you're endorsing that behavior.

>After all you have answered many questions in the past so you should know that this can and will always happen.

I have answered a lot of questions and it's based on that experience that I'm speaking.

It's actually pretty rare that someone else will take what I say and post it as an answer.

When it happens, it's usually an innocent error and the person politely retracts.

Again, I'm amazed that you think it's all right.


mblase, I wasn't trying to seem mean-sprited with my comment.  I'm sorry if that's the way it seemed.

But this forum is a community with etiquette.  I realize that you're not that experienced on this site and this whole thing is not really that big of a deal.

But you should know that if you go around doing that, you're going to upset some people.  And I would be remiss as an "experienced" denizen of this forum if I didn't pass on to you that that behavior is not appreciated.

On the plus side, it's good that you knew the answer and I'm sure mnewnham will appreciate the solution regardless of the source.

mnewnham, if my opinion matters to you and you find mblase's answer helpful, please feel free to award him the points.  I withdraw from the question.

Quick EE primer:
================

Do not post something as an answer unless you are positive that you have the definitive answer and that it is unique from other postings.

If you post a comment that has merit, the questioner will usually award you points.

It is very common to post as a comment and wait for the questioner to tell you to post for points.

Points are not as important as maintaining a quality environment.
Avatar of mnewnham

ASKER

As an HTML beginner, what I really was looking for was code samples: mayhews comment doesn't really assist me. I will evaluate the examples supplied by mblase and eqbservices and based on which I believe fits my requirements the best, award the points to that person.

As a general comment:

1. remember that you are the experts, and what may appear obvious to you is a giant leap in comprehension to the rest of us.

2. Answers to questions is an inappropriate place for inter-expert squabbles.
Ok, mblases response is pretty good, but I want it to do one more thing. It reloads the parent frame ok, but if that frame is itself in a frame, the outermost frame reloads it's default pages. How can i stop it doing this.

I have upped the points to 100.
Are you saying that you want each page to detect whether it's in a frame.. and if not, to load a frameset AND then place itself in that frameset ?

Unless you want to write a frameset page for "every" page, it becomes a little complex.

if you just wish to launch the "site" in a frame, and let them navigate to that page, then it is a simple matter..

in each page you want to detect, use:

if(top==self)
  top.location = 'http://mysite.com/frameset.htm';


Brian
( as declared earlier by eqbservices.. )
Not quite what I was looking for but reasonably close.