WebDevelopersNotes logo

home-icon Home / HTML / Preventing web pages from load in frames

Preventing web pages from load in frames

Preventing web pages from load in frames

Once your site is well known, other developers might place links to it loading your pages in the same window or another browser window. This is fine since your site is presented the way you wanted it to be.

What if developers load your pages in a frame along with their interface? This almost amounts to stealing data! The problem is aggravated by the fact that you don’t know who is doing it or where your pages are ultimately displayed.

Here is a simple JavaScript code protects your pages from being stolen.

<script type="text/javascript">

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


The code tests whether the top page is the same as the page being displayed. If this is not the case, the URL of the top page is changed to the URL of the present page. Thus, your page always loads in a full browser window the way you wanted it.
Place this script in the HEAD section of each document you want to protect.

Sponsored Links

Your comments
Star icon IMPORTANT Have a question / problem? Click here to ask an expert.

Sponsored Links


How do I view a deleted web page?
Is there a way to view a deleted web page - one that is no longer available? Yes there is and the solution is quite simple. [more...]


The name "Siri" is of Norwegian origin and is a short form of Sigrid meaning a "beautiful woman who leads you to victory". So now you know what Siri means! [more...]

We use cookies to give you the best possible website experience. By using WebDevelopersNotes.com, you agree to our Privacy Policy