iframe 拒绝显示

新手上路,请多包涵

我正在尝试将一个简单的 iframe 加载到我的网页之一,但它没有显示。我在 Chrome 中收到此错误:

 Refused to display 'https://cw.na1.hgncloud.com/crossmatch/index.do' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self' https://cw.na1.hgncloud.com".

Invalid 'X-Frame-Options' header encountered when loading 'https://cw.na1.hgncloud.com/crossmatch/index.do': 'ALLOW-FROM https://cw.na1.hgncloud.com' is not a recognized directive. The header will be ignored.

这是我的 iframe 的代码:

 <p><iframe src="https://cw.na1.hgncloud.com/crossmatch/" width="680" height="500" frameborder="0"></iframe></p>

我不太确定那是什么意思。我以前加载过很多 iframe,但从未收到过此类错误。

有任何想法吗?

原文由 Jose M. 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 926
2 个回答

这意味着位于 cw.na1.hgncloud.com 的 http 服务器发送一些 http 标头来告诉像 Chrome 这样的网络浏览器允许 iframe 加载该页面( https://cw.na1.hgncloud.com/crossmatch/ )仅来自在同一域 (cw.na1.hgncloud.com) 上托管的页面:

 Content-Security-Policy: frame-ancestors 'self' https://cw.na1.hgncloud.com
X-Frame-Options: ALLOW-FROM https://cw.na1.hgncloud.com

你应该阅读:

原文由 Vince 发布,翻译遵循 CC BY-SA 3.0 许可协议

错误的原因是 https://cw.na1.hgncloud.com 的主机服务器提供了一些 HTTP 标头来保护文档。其中之一是框架祖先必须来自与原始内容相同的域。您似乎正试图将 iframe 放置在与 iframe 内容不同的域位置 - 因此违反了主机设置的内容安全策略。

查看 内容安全策略 上的此链接以了解更多详细信息。

原文由 David 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题