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

How to iframe a page from same domain with X-Frame-Options SAMEORIGIN?

本文关键字:iframe X-Frame-Options 何使用 SAMEORIGIN      更新时间:2024-05-01

我们有这个页面,www.ourdomain.com/home.html

在home.html中,有一个iframe,其src设置为yyy.ourdomain.com/index.html。yyy.ourdomain.com上的所有页面都将X-Frame-Options设置为SAMEORIGIN。由于这个头,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标题的选项。

谢谢。

标题X-Frame-Options: DENYX-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

有关更多信息,