问题描述
- http://testing.avg.163.com/embedGamePlayer 网址在浏览器可以直接打开。
- http://aaa.com/index.html 页面
iframe src
里面,无法加载: http://testing.avg.163.com/embedGamePlayer,并且控制台抛出如下错误:
Refused to display
“http://testing.avg.163.com/embedGamePlayer”in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors
“http://abc.com https://def.com”.
问题原因
- http://testing.avg.163.com/embedGamePlayer 的 Response Headers 信息如下:
Content-Security-policy: frame-ancestors
http://abc.com http://def.com
frame-ancestors
没有设置允许父级页面域名http://aaa.com,所以在iframe 中无法访问
解决办法
- 在父级页面加入,意思是为
frame-ancestors
政策设置一个或多个来源:
<meta http-equiv="Content-Security-Policy"
content="frame-ancestors 'self'
https://aaa.com ">