Iframe breakout

20.Aug.2010

Sometimes, you don’t want your website to be displayed on other websites inside of an iframe. It is easy to protect your website from being displayed inside of iframe by using following JavaScript iframe breakout snippet:

1
2
3
4
5
6
7
8
<script>
function get_out_of_iframe() {
	if (top.location.href != self.location.href)
		top.location.href = self.location.href;
}
 
window.onload = get_out_of_iframe();
</script>