Prevent Framing of Your Web Site With JavaScript

Tags:

I found a nice tip on Filination.com about removing the top frame when other sites try to frame your Web site in a frame. Some common examples are Google Images and Netscape.com.

Here is the code to prevent other Web sites from showing your site inside of a frame:

<script language="JavaScript" type="text/javascript">
    if (top.location != self.location) top.location = self.location;
</script>

Paste the above code just after the opening <body> tag. If your site is loaded in a frame the JavaScript code will redirect to your site without the frame.

Average: 5 (1 vote)