我正在尝试将一个简单的 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 并且从未收到过此类错误。
有任何想法吗?
错误的原因是 https://cw.na1.hgncloud.com 的主机服务器提供了一些 HTTP 标头来保护文档。其中之一是框架祖先必须来自与原始内容相同的域。您似乎正试图将 iframe 放置在与 iframe 内容不同的域位置 - 因此违反了主机设置的内容安全策略。
查看 Content Security Policy 上的此链接以获取更多详细信息。