TomA
TomA

Reputation: 3

How to break out of an iFrame when a pop up is in front?

My site has been copied via an iframe and I can't break out, I think because there is a popup infront of the iframe.

This site http:// facebvook . info/claim.html (I broke the link so they don't get a backlink) is the offending site, my site is visible behind the popup.

I've tried the following javascript in my header:

if (top != self) {
  top.location.replace(document.location)
  alert('busting you out, please wait...')
}

But it doesn't work.

What I ideally want is for my site not to load in the iframe at all, but any other soloution would be good too.

Upvotes: 0

Views: 645

Answers (1)

Celmaun
Celmaun

Reputation: 24762

You can send the X-Frame-Options header with a value of 'SAMEORIGIN' to prevent other sites from embedding your site.

In PHP you can do that like this:-

<?php header( 'X-Frame-Options: SAMEORIGIN' ); ?>

Or if you have mod_headers enabled you can create an .htaccess file in your document root with the following text:-

Header always append X-Frame-Options SAMEORIGIN

Upvotes: 2

Related Questions