Err: Connection timed out [110] How to keep your website from being framed

How to keep your website from being framed

My interest in this topic when Lori Deschene, the author of this post, wrote about her website being put in a frame by BlogHer.

Having your website in a frame can confuse your visitors into thinking that your website is part of another branding that isn’t yours. It call also mess up the URL and screws up bookmarks and link-sharing. I don’t want to dwell too much on why frames are bad, but I want to show you a way to free your website in case your website ends up being in somebody’s frame.

All you need is a small piece of JavaScript in the <head> section of your HTML code.

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

If you use WordPress, the plugin WP Frame Breaker can do that for you automatically, provided that your theme allows modifications in the <head>.

With this, when a websites decide it’s right to put your website in a frame, your website will be able to break free and your URL will show up in the address bar as it should.

Comments