Last month, I found out that someone was loading one of my pages in his website using a frame. Whenever the website is loaded, my page will appear as if it was the owner’s. I do not know what this person is trying to do or gain from it but I found a method to defeat it.
There is an article at Web Developers Notes on how to prevent web pages from loading in frames. You only need to insert the javascript code below in the HEAD section of the document that you would like to protect.
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
if (self != top)
{
top.location.href = self.location;href;
}
//-->
</SCRIPT>
How does it work?
The paragraph below is quoted from the article. It explains how and what the code does.
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.
Verdict
I have tried it out and it works like a charm. Try clicking here to check out the previous website that was loading my page in a frame. Now, the page redirects to my original page. Notice the URL at the top of the page shows it is loaded from my blog.
If you want to prevent others from loading any of your pages in a frame, use the code provided above.

I remember reading or heard Jeff Ooi praising Nuffnang and mentioned that if he were to join either one of the two blog ad aggregators in Malaysia, it would have been Nuffnang. 


Recent Comments