我正在尝试将一个简单的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.
Run Code Online (Sandbox Code Playgroud)
这是我的iframe的代码:
<p><iframe src="https://cw.na1.hgncloud.com/crossmatch/" width="680" height="500" frameborder="0"></iframe></p>
Run Code Online (Sandbox Code Playgroud)
我不太确定这意味着什么.我以前加载了很多iframe,但从未收到过这样的错误.
有任何想法吗?
谢谢
Vin*_*nce 50
这意味着http服务器在cw.na1.hgncloud.com发送一些http标头时告诉Chrome等网络浏览器只允许从同一域上托管的网页加载该页面(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
Run Code Online (Sandbox Code Playgroud)
你应该读到:
出错的原因是https://cw.na1.hgncloud.com的主机服务器提供了一些HTTP标头来保护文档.其中之一是框架祖先必须来自与原始内容相同的域.您似乎试图将iframe放在与iframe内容不同的域位置 - 因此违反了主机设置的内容安全策略.
有关详细信息,请查看内容安全策略中的此链接.