To check if your web page is blocked from loading in iframe, If you use…
How to check whether a web page can be loaded in iframe

Sometimes you want to load other web page in your website’s iframe, but due to security concerns, other website may have security configuration that prevent your website from loading their pages in to the iframe. In this case, if you want to load them into your iframe, you will see the error like screenshot below:

To prevent a page from loading in iframe, the response header will send to the browser with option which denies the load. This already talked in this topic How to block website from loading in iframe.
The below PHP script will tell you if the website allow to load in iframe:
function isIframeDisabled($src){
try{
$headers = get_headers($src, 1);
$headers = array_change_key_case($headers, CASE_LOWER);
// Check Content-Security-Policy
if(isset($headers[strtolower('Content-Security-Policy')])){
return true;
}
// Check X-Frame-Options
if(isset($headers[strtolower('X-Frame-Options')] &&
(strtoupper($headers['X-Frame-Options']) == 'DENY' ||
strtoupper($headers['X-Frame-Options']) == 'SAMEORIGIN')
){
return true;
}
} catch (Exception $ex) {
// Ignore error
}
return false;
}
This Post Has 0 Comments