I\'m writing a tiny webpage whose purpose is to frame a few other pages, simply to consolidate them into a single browser window for ease of viewing. A few of the pages I\'
Try this thing, i dont think anyone suggested this in the Topic, this will resolve like 70% of your issue, for some other pages, you have to scrap, i have the full solution but not for public,
ADD below to your iframe
sandbox="allow-same-origin allow-scripts allow-popups allow-forms"
I had a similar issue, where I was trying to display content from our own site in an iframe (as a lightbox-style dialog with Colorbox), and where we had an server-wide "X-Frame-Options SAMEORIGIN" header on the source server preventing it from loading on our test server.
This doesn't seem to be documented anywhere, but if you can edit the pages you're trying to iframe (eg., they're your own pages), simply sending another X-Frame-Options header with any string at all disables the SAMEORIGIN or DENY commands.
eg. for PHP, putting
<?php
header('X-Frame-Options: GOFORIT');
?>
at the top of your page will make browsers combine the two, which results in a header of
X-Frame-Options SAMEORIGIN, GOFORIT
...and allows you to load the page in an iframe. This seems to work when the initial SAMEORIGIN command was set at a server level, and you'd like to override it on a page-by-page case.
All the best!
It's surprising that no one here has ever mentioned Apache
server's settings (*.conf
files) or .htaccess
file itself as being a cause of this error. Search through your .htaccess
or Apache
configuration files, making sure that you don't have the following set to DENY
:
Header always set X-Frame-Options DENY
Changing it to SAMEORIGIN
, makes things work as expected:
Header always set X-Frame-Options SAMEORIGIN
If you are getting this error while trying to embed a Google Map in an iframe
, you need to add &output=embed
to the source link.
I had same issue when I tried embed moodle 2 in iframe, solution is Site administration ► Security ► HTTP security
and check Allow frame embedding
Use this line given below instead of header()
function.
echo "<script>window.top.location = 'https://apps.facebook.com/yourappnamespace/';</script>";