【发布时间】:2016-06-13 21:15:14
【问题描述】:
我在我的网页中嵌入了一个 iFrame,如下所示:
var iframeProps = {
'data-type': self.props.type,
allowTransparency: self.props.allowTransparency,
className: self.props.className,
frameBorder: self.props.frameBorder,
height: self.props.height,
key: url,
onLoad: self.props.onLoad.bind(self),
scrolling: self.props.scrolling,
src: self.state.isActive ? url : '',
style: self.props.styles,
width: self.props.width
};
<iframe {...iframeProps} />
这会在控制台中引发错误
拒绝在框架中显示 'https://twitter.com/....,因为祖先违反了以下内容安全策略指令:“frame-ancestors 'self'”。
谁能告诉我如何才能完成这项工作?
【问题讨论】:
-
如果网站不允许使用带有 frame-ancestors 或 X-Frame-Options 的框架,您根本无法 iframe。根据来源和您需要的内容,可能有可用的 API 或 SDK。所以说真的,你不能让你正在做的事情发挥作用,但你可以通过利用他们认可的界面系统来以不同的方式处理它。
标签: iframe