【发布时间】:2021-09-27 07:50:42
【问题描述】:
我需要第三方网站才能在我网站的 iframe 中运行。第三方网站在 FireFox 的 iframe 中完美运行。在 Chrome 中,出于某种原因,用户只被允许登录,然后他们点击的任何链接都会将他们带回登录页面(这是 iframe 的默认页面)。
所以我寻找了一个解决方案,似乎我需要创建一个内容安全策略。我以前从未使用过内容安全策略,所以我不知道该怎么做。
我遇到了一篇带有元标记示例的帖子,我尝试了其中的几种变体,但无论我如何尝试,在 Chrome 中,页面甚至都无法加载到 iframe 中。
<html>
<head>
<title>Student Portal</title>
<link rel="shortcut icon" href="favicon.ico">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://<third party site>; img-src https://*; child-src 'self' https://<third party site>; script-src 'self' https://<third party site>; style-src 'self' https://<third party site>;" />
</head>
<body>
<!-- rest of my code -->
</body>
</html>
我也尝试了 <embed> 元素,但得到了相同的结果。
是否有另一种创建内容安全策略的方法,或者可能是其他完整的解决方案?
任何帮助将不胜感激
【问题讨论】:
标签: html header content-security-policy