问题描述
我正在尝试在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.
这里有一个文档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'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!