拒绝显示一个框架,因为它将'X-Frame-Options'设置为'sameorigin' [英] Refused to display a frame because it set 'X-Frame-Options' to 'sameorigin'

查看:42502
本文介绍了拒绝显示一个框架,因为它将'X-Frame-Options'设置为'sameorigin'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在ionic3中设置iframe,但我面临这个问题拒绝显示一个网页框架。

I am trying to set a iframe in the ionic3 but I am facing with this problem Refused to display a frame of webpages.

这是我的代码。

 <ion-content>
      <div #frame style="width:100%; height:100%; overflow:scroll !important;-webkit-overflow-scrolling:touch !important">
        <iframe [src]="url" class="iframe" scrolling="yes" ></iframe>
      </div>
    </ion-content>

 onInput() {
    this.open = true;
    this.url = this.domSanitizer.bypassSecurityTrustResourceUrl('https://www.youtube.com/embed/results?search_query=' + this.myInput);
}


推荐答案

当您发送请求时 GET POST iframe(GET)等。您的浏览器或WebView会在请求标头中添加一个标题为 原点。标题 CAN'T 可以改变它。

When you send a request like GET, POST, iframe (GET), etc. Your browser or WebView adds by deffault a header in "Request-Headers" with name "origin". That header, CAN´T be change it.

在您的情况下,我可以看到您试图嵌入的网址:https://www.youtube.com / embed / results?search_query = + this.myInput但是Youtube的文档说的网址必须是:http://www.youtube.com/embed/ VIDEO_ID?origin = http://yourPage.com

In your case, I can see than the url you are trying to embed it´s: "https://www.youtube.com/embed/results?search_query= + this.myInput" but Youtube´s documentation say than the url must be: "http://www.youtube.com/embed/VIDEO_ID?origin=http://yourPage.com".

当您使用< iframe> 使用Youtube,总是你必须在链接的参数中发送一个来源。

When you use <iframe> with Youtube, ALWAYS you have to send a origin in parameters of the link.


来源:
此参数为IFrame API
提供额外的安全措施,仅支持IFrame嵌入。如果您使用IFrame
API,这意味着您要将enablejsapi参数值设置为1,
您应始终将您的域指定为原始参数值。
https://developers.google.com/youtube/ player_parameters?hl = zh-419#origin

这里有一个文档de Youtube的链接: https://developers.google.com/youtube/player_parameters?hl=en-419

Here you have a link to documentation de Youtube: https://developers.google.com/youtube/player_parameters?hl=en-419

问候!

这篇关于拒绝显示一个框架,因为它将'X-Frame-Options'设置为'sameorigin'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆