Prevent page opening on iframe?

How to prevent page opening in iframe using PHP? How is gmail inside iframe?

+3
source share
3 answers

For PHP you can use.

header("X-FRAME-OPTIONS: DENY");

This is only supported on modern browsers, IE8 +, Firefox 3.6.9, Safari 4, and Chrome. For an older browser, you will also need JavaScript.

+8
source

You can do it using JavaScript

if( (self.parent && !(self.parent===self))
    &&(self.parent.frames.length!=0)){
    self.parent.location=document.location
}

This will be redirected from the page that opens your page in an iframe on your page.

+6
source

PHP, - iframe. PHP , - .

JavaScript, , , , - .

+4

Source: https://habr.com/ru/post/1791015/


All Articles