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'm trying to frame forbid being framed and throw a "Refused to display document because display forbidden by X-Frame-Options." error in Chrome. I understand that this is a security limitation (for good reason), and don't have access to change it.
Is there any alternative framing or non-framing method to display pages within a single window that won't get tripped up by the X-Frame-Options header?
i had this problem, and resolved it editing httd.conf
i changed SAMEORIGIN to GOFORIT and restarted server
You can bypass
X-Frame-Options
in an<iframe>
using just client-side JavaScript and YQL. Here is a proof of concept: Hacker News in an<iframe>
. (Tested in Chrome & Firefox; if it doesn't work, try refreshing the page.)The process is as follows:
loadURL
),getData
),<base link>
and a<script>
loading links in an iframe using YQL as well,<iframe>
(functionloadHTML
).The sample JS code:
It appears that X-Frame-Options Allow-From https://... is depreciated and was replaced (and gets ignored) if you use Content-Security-Policy header instead.
Here is the full reference: https://content-security-policy.com/
Solution for loading an external website into an iFrame even tough the x-frame option is set to deny on the external website.
If you want to load a other website into an iFrame and you get the
Display forbidden by X-Frame-Options”
error then you can actually overcome this by creating a server side proxy script.The
src
attribute of the iFrame could have an url looking like this:/proxy.php?url=https://www.example.com/page&key=somekey
Then proxy.php would look something like:
This by passes the block, because it is just a GET request that might as wel have been a ordinary browser page visit.
Be aware: You might want to improve the security in this script. Because hackers could start loading in webpages via your proxy script.
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 same issue when I tried embed moodle 2 in iframe, solution is
Site administration ► Security ► HTTP security
and checkAllow frame embedding