How to prevent sites from loading your site in a frame?
Written on
December 24, 2008 at 2:58 am by
mkyong
Question
Today i received an email regarding “How can i prevent my website load from a frame“? He keep complaints about others site load his website into a frame and pretend the content is their own website. He asking about whether i have a solution for him?
Solution
Yes, We can prevent it by a simple Javascript code. Please copy and paste following code into your body of HTML code.
<SCRIPT LANGUAGE="JavaScript"> if (window != top) top.location.href = location.href; </SCRIPT>
Above Javascript will detect whether your website is load through frame. If yes, it will redirect it to your website. Hope it help.


And what if the guys load your site in an image tag