开发者

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

开发者 https://www.devze.com 2023-04-12 15:56 出处:网络
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.

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 th开发者_运维知识库e 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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消