DelphiFAQ Home Search:
General :: Web publishing
Information about web publishing, how to maintain, optimize and promote a web site.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

Framebusting (reload a framed page outside the frame)

Question:

I noticed that some web sites like www.about.com include some articles off my web sites in a frame. I'd like to detect this and reload my article so that my domain name shows in the browser's address bar. How can I break out of those frames?

Answer:

Many webmasters use Javascript which is executed in the user's browser to do this. The following Javascript will do the trick. Make sure to place it in the HEAD section before the BODY tag. That way the page gets reloaded before the whole page has been loaded.

<script type="text/javascript">
 if( window!= window.top ) { top.location.href = location.href; }
 </script>


If you work with Apache and have access to the .htaccess file, you can use the rewrite engine in Apache. Put the following code in your .htaccess file (and replace delphifaq.com with your domain name, of course):


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^delphifaq.com
RewriteRule ^(.*)$ http://www.delphifaq.com/$1 [R=301,L]



Generated 16:01:55 on Aug 15, 2018