我正在尝试将一个简单的 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,但从未收到过此类错误。
有什么想法吗?
最佳答案
这意味着位于 cw.na1.hgncloud.com
的 http 服务器发送一些 http header 来告诉像 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
你应该阅读:
关于html - iframe 拒绝显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31944552/