我们有这个页面,www.ourdomain.com/home.html
在 home.html 中,有一个 iframe,其 src 设置为 yyy.ourdomain.com/index.html。 yyy.ourdomain.com 上的所有页面都将 X-Frame-Options 设置为 SAMEORIGIN。由于此 header ,iframe 内容不会加载。我收到此错误。
Firefox - X-Frame-Options 拒绝加载:http://yyy.ourdomain.com/index.html不允许跨源框架。
Chrome - 拒绝显示“http://yyy.ourdomain.com/index.html” ' 在框架中,因为它将 'X-Frame-Options' 设置为 'SAMEORIGIN'。
home.html 和 index.html 都有这行 JavaScript 代码 -
document.domain = 'ourdomain.com';
我怎样才能做到这一点?
PS - 我无法选择删除 X-Frame-Options header 。
谢谢。
最佳答案
header X-Frame-Options: DENY
或X-Frame-Options: SAMEORIGIN
不会允许您以任何方式呈现 <frame>
中的页面, <iframe>
或<object>
.
我发现的唯一工作方法是在主域中创建一个代理页面,加载所请求的子域页面的 html 内容。
参见
- https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
- https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
了解更多信息
关于javascript - 如何使用 X-Frame-Options SAMEORIGIN 对来自同一域的页面进行 iframe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28684040/