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.
Stumble it!
Share it!
Subscribe to my feed
but using this will prevent others from using a web proxy or a translation service from viewing your page.
eh
I also accidentally put you page in my frame.
here = http://beraspadu.blogspot.com/
but I also dont want it to be happened.
any idea how to make any link in a page to be as target=_new ?
fyi, html inside the frame was not generated by me.
the opposite of your tutorial.
@CincauHangus
I tested and it works.
1) HideMyAss (web proxy): Click here.
1) Google translation: Click here.
@Hasbullah Pit
What you are doing is different from the situation I mentioned in my post, so it is ok. This post is to prevent people from loading the entire web page as a frame. Yours only take roughly a paragraph and a link, which is not too bad.
Yours works like an aggregator. However, there may be some people who do not like it though. Depends on individual bloggers.
Nope
you visit the page after modification.
before this i use “rss2html” to display the content, and the page were actually embed inside frame.
Then i use RSSinlude, it load page in new window.
I actually want to give free link for my visitor without having much of static link in the blog page.
Yeah I know some people may not like it. They may request from me to remove their site.
@Hasbullah Pit
Oh, ic. Sorry that I didn’t get to see the page before the mod. Back to the question on how to load a new page in new window:
target=”_blank”