javascript - 如何使用 X-Frame-Options SAMEORIGIN 对来自同一域的页面进行 iframe?

标签 javascript html iframe

我们有这个页面,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: DENYX-Frame-Options: SAMEORIGIN不会允许您以任何方式呈现 <frame> 中的页面, <iframe><object> .

我发现的唯一工作方法是在主域中创建一个代理页面,加载所请求的子域页面的 html 内容。

参见

了解更多信息

关于javascript - 如何使用 X-Frame-Options SAMEORIGIN 对来自同一域的页面进行 iframe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28684040/

相关文章:

css - iframe/span 下的链接无法点击

javascript - 使用 php 在谷歌图表中获取值

javascript - 使用 JQuery 在 ESC 按键处关闭自定义框

javascript - 将查找字段设置为仅显示联系人

javascript - Twitter Bootstrap 导航图标加载器

html - 如何设置第二个div的高度

Javascript 清除监听器和变量

html - IE 中列表项后的边距

javascript - 使用 insertHTML 的 execCommand 的 iframe 撤消/重做(contenteditable)

javascript - Microsoft Edge - 嵌入式 PDF - 如何打印