I\'m tring to embed a webpage in an iframe, but it doesn\'t work at all. internal pages with relative path are displayed normally. but this simple code doesn\'t work:
<Because the internal page had do something to prevent to be put in iframe.
Maybe a piece of javascript like that
if (window.top != window.self) {window.top.location = window.self.location;}
Suppose your url is www.google.com, i.e $url = "www.google.com";
$headerRes = get_headers($url); //get the header response
foreach($headerRes as $val)
if($val=="X-Frame-Options: SAMEORIGIN" || $val=="X-Frame-Options: DENY"){
header("location:".$url);
exit;
}
//simply redirect to their website instead of showing blank frame
I hope I explained myself good.
Google uses an X-FRAME-OPTIONS HTTP header to disallow putting their pages in iframes: https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header
Almost all modern browsers will refuse to put pages with this HTTP header in an iframe. There's nothing you can do about that.