How to stop being framed!!!

I have an existing homepage and having problems
with being framed by other websites. For example
when my page is linked from a website using
frames, my page(s) appear as a frame-let.

I would like to know whether there is any HTML
that I can add to prevent this so that my page is
always displayed using the full browser screen
and the location of the URL displayed correctly.

I would prefer a non Java-script solution if
possible. The solution is required for every page
on my site not just the front page. Thanks

Colin

Colin
yckAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blackEyEzCommented:
<A HREF="mywebpage.html" TARGET="parent"> = Using the whole browser window without frames for mywebpage.html

<A HREF="mywebpage.html" TARGET="_blank"> = Opens a new browser for mywebpage.html
0
oubelkasCommented:
Well, I'm sorry, but no way you can just solve this with plain HTML. However with javascript it can be solved. It's only one function and one onload event handler.

The function :

<script language="javascript">
<!--
function NotFramed(){
if (parent.frames.length != 0) {
  // loaded in frames
window.location.href="http://myurl.com";
}
else {
  // not loaded in frames
}
}
//-->
</script>

then in the onload of the body call this function:

<body onLoad="javascript:NotFramed();">

Now, if the page is loaded in frames, it goes to the defined url else nothing...

This must do the trick ;)

Joseph
0
knightEknightCommented:
You might try something like this:

<HTML>
<HEAD>
<SCRIPT language='javascript'>
window.name = "ThisIsMYWindow";
if ( top.name != window.name )
{
   top.location = self.location.href;
}
</script>
</head>


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mblaseCommented:
Based on BlackEyEz' solution: add <BASE TARGET="_top"> to every page on your website, between the </HEAD> and <BODY> tags. This won't keep the pages from being framed, but any hyperlink clicked from your page will automatically load over any framesets -- so you'll never be framed more than once.

If you want your pages to never be framed at all, then you need to use one of the JavaScript solutions posted here.
0
DreamMasterCommented:
no mblaze.....You don't wanna do that!

if You do it like that You will get every page loading without the frameset.

The only possible solution is to (in the frameset page) detect (using javascript) whether Your frameset is at the top of the frameset..if it isn't jump out and display it as it should be..

actually this is pretty simple...

just use:

<script language="javascript">
<!--
if window.location != '<Your URL>'
  {
    top.location.replace('<Your URL>');
  }
//-->
</script>

that should do the trick, it does for me... i couldn't help myself...i HAD to respond to this...

good luck..
0
yckAuthor Commented:
knightEknight's answer seems the best as it works and satifies my requirements.. Plus its just an
extra line on each page :8)

<HTML>
<HEAD>
<SCRIPT language='javascript'> window.name = "ThisIsMYWindow"; if ( top.name != window.name ) { top.location = self.location.href; } </SCRIPT>
<TITLE>hello world</TITLE>
</HEAD>
hello


hello buddy
</HTML>
0
DreamMasterCommented:
with my code You would have lost another line...and it's just as easy, but i guess my answer came to late...sorry will respond sooner next time....

Max out!
0
oubelkasCommented:
Yep, I agree, knight's the winner here...

Joseph
0
blackEyEzCommented:
No, <b>dream</b> is the winner here..:)
0
yckAuthor Commented:
Hello, I still think knightEknight still wins because
DreamMaster's requires hardwiring the URL
within the webpage. This can be a problem if you
develope your page off-line or have mirror sites.

This is the sort of coding I'll use where window.name
MUST be reset to a different value for each page.
If this is not done the second page on my site can
be reframed again. I suppose each webpage should
have its own "tag" such as something to do with
its filename for example.

Thanks all for your help.

<HTML>
<HEAD>
<SCRIPT language='javascript'> window.name = "page1"; if ( top.name != window.name ) { top.location = self.location.href; } </SCRIPT>
<TITLE>hello world</TITLE>
</HEAD>
hello
<A HREF="page2.htm">click</A>

hello buddy
</HTML>
0
oubelkasCommented:
Hey, but mine wasn't bad either ;)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.