homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Frame buster scripts
Why are they all different?!

 9:49 pm on Jan 21, 2005 (gmt 0)

I have been looking at frame breaking scripts, but I only get confused. How can there be so many different versions, all of which claim to do about the same thing? Some are to be put in the Head, some in the Body. Some start with:

<script type="text/javascript">
other with:
<script language="javascript">
yet other with:
<script typ="text/javascript" language="JavaScript">

String alternatives include:
if (top!= self)
top.location.href = self.document.location;

if (parent!= self)
{top.location.href = location.href}

if (top.frames.length!=0)

if (window!= window.top)
top.location.href = location.href;

if (self!= top) top.location.href = self.location.href;

if (parent.frames.length > 0) {
parent.location.href = location.href;

if (top.location!= location)
top.location.href = document.location.href ;

if (top!= self) top.location.href = location.href;

jdMorgan has an interesting and rather recent solution at:

EVERY script I have seen is different! Why? My own site is unframed and like most I would only need something simple that works in modern browsers and preferrably does not disable the Back button.

Finally, I also found this:
<meta http-equiv="window-target" content="_top">
It would be nice if it works, as some people browse JS disabled. Could having both Meta and Script on my page solve that problem?



 9:57 pm on Jan 21, 2005 (gmt 0)

Why are there differences?

Simply because there is more than one way to get the job done.

I like to put javascript in extenal files and call the code with a one-liner in the <head> section, javascript being the last stuff in the head section before the ending </head> tag.


Just look at Windows. To close a window: use Alt-F4, or click the X at top-right, or click the image at top-left and then click "Close" in the drop down list that appears, or press Control-X, or...


 12:20 pm on Jan 22, 2005 (gmt 0)

You should always use location.replace(newurl) otherwise the back button breaks.


Bernard Marx

 1:19 pm on Jan 22, 2005 (gmt 0)

Doesn't that give the possibility of an "access denied".
(Not a rhetorical question).


 1:48 pm on Jan 22, 2005 (gmt 0)

Hello Kaled:

" You should always use location.replace(newurl) otherwise the back button breaks."

Very good advice! I did exactly that from earlier advice you kindly provided.
I tried various methods but your's was the best.

There is only one downside, my _apparent_ hits counts dropped.
Why? Because formerly, people would back out of my framed page, only to wind up in
the referring page .. back and forth endlessly!

Now, they end up in a new window and the tennis-ball effect is eliminated.
Sure, my hit counts are lower, but they are also more realistic. Thanks again - Larry


 1:52 pm on Jan 22, 2005 (gmt 0)

Another good discussion about frame-breakers here:



 3:27 pm on Jan 22, 2005 (gmt 0)

Thank you, encyclo. I only searched this site for "frame breaking" and "frame buster", but not for "frame breaker".

But what is the difference between "text/javascript" and just "JavaScript" in the beginning?

Is anyone able to comment on that Meta solution at the end of my OP?


 3:34 pm on Jan 22, 2005 (gmt 0)

Hello Encyclo:

I hope this isn't too divergent from the main thread here. But!
How do you feel when some valued page(s) of yours are framed by another site?

Personally, I feel somehow insulted or ripped off.

It is as if the other site is including your or my work as a part of theirs..
that they somehow own your works.

I hope that the major SEs pass PR and any other credits normally given
via a straight link to any site that is "framed".

Not to do so would be an injustice to the browsing public, not to mention the source. - Larry


 4:51 pm on Jan 22, 2005 (gmt 0)

The type="text/javascript" is a REQUIRED attribute. It must be there for your HTML page to be valid code.

The language="javascript" is an older attribute, for some ancient browser (IE3?, NS3?, NS4?, so long ago I no longer remember), and can be left out if you want.

Add a DOCTYPE above the first <html> tag, and then run the page through [validator.w3.org ] to make sure there are no other HTML coding errors.


 2:37 pm on Jan 24, 2005 (gmt 0)

I hope this isn't too divergent from the main thread here. But!
How do you feel when some valued page(s) of yours are framed by another site?

Larry, I use a frame-busting script on every single page of every site I control - I dislike any framing of my contents under almost any circumstances. I don't think I'm the only person here with that opinion!


 5:45 am on Jan 26, 2005 (gmt 0)

Hi encyclo: I put in frame busters on all my pages too.
Now, as I rewrite them one or two a day for other reasons,
I change the buster to Kaled's method (see above) which works even better. - Larry


 7:58 pm on Mar 5, 2005 (gmt 0)

What about frames from within your own site? Especially iframes? Does this bust your own frames as well, or only others outside your site from framing your site?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved