Html 无法在iFrame内部加载数据

Html 无法在iFrame内部加载数据,html,reactjs,sockets,websocket,Html,Reactjs,Sockets,Websocket,我试图获取旧网站的URL,但发生了错误: Fetch API cannot load http://xyz. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://abc' is therefore not allowed access. If an opaque response serves your needs, set the request's mode

我试图获取旧网站的URL,但发生了错误:

Fetch API cannot load http://xyz.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://abc' is therefore not allowed access.
If an opaque response serves your needs, set the request's mode to 'no-cors'
to fetch the resource with CORS disabled.
我的代码如下所示

render(){
    return (
       <div>
          <iframe src="http://localhost:8080/.../StockExchangeWidget.html" />
       </div>
    )
}
render(){
    return (
        <div>    
            <iframe
                sandbox="allow-same-origin"
                title="FirstIFrame"
                src="http://www.tricky.web.siteHome.do"
            />    
        </div>
    )
}
当我在iFrame之外加载它时,一切都正常,但是当我尝试用iFrame加载它时,我会得到很多错误,但只针对图表的数据,正如您可以看到的,框架和按钮都被加载了

当我试图在url中加载HTML页面时,我也遇到了WebSocket错误
WebSocket连接到'wss://widgetdata.tradingview.com/socket.io/websocket?from=widgetembed%2F&date=2018_06_09-17_59'失败:WebSocket握手过程中出错:意外响应代码:403

承载iframe的域需要修改其名称,以允许来自域的请求到达其站点。如果该页面上没有CORS标题,出于安全原因,您的浏览器将不会呈现iframe的内容。

是的,答案如PANAYIOTIS所指

我的代码现在看起来像这样

render(){
    return (
       <div>
          <iframe src="http://localhost:8080/.../StockExchangeWidget.html" />
       </div>
    )
}
render(){
    return (
        <div>    
            <iframe
                sandbox="allow-same-origin"
                title="FirstIFrame"
                src="http://www.tricky.web.siteHome.do"
            />    
        </div>
    )
}
我在iframe中添加了sandbox=allow home origin,解决了所有“cookie”和“无法上传”问题

欲了解更多信息,请阅读这本书,它非常适合解决此类问题: