嵌入youtube视频“拒绝显示文档,因为X-Frame-Options禁止显示” [英] Embedding youtube video "Refused to display document because display forbidden by X-Frame-Options"

查看:121
本文介绍了嵌入youtube视频“拒绝显示文档,因为X-Frame-Options禁止显示”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 < p< p>< p>< ; iframe width = \\'155 \\'height = \\'315'src ='http://www.youtube.com/watch?v =< video id>& amp; amp; output = embed' frameborder = \''''allowfullscreen>< / iframe> 

但是当我尝试添加这个时,我得到这个错误。在Chrome中检查页面后,我在控制台标签中看到此错误



拒绝显示文档,因为X-Frame-Options禁止显示



我甚至无法在IE和Firefox中看到视频

我甚至尝试添加

  header('X-Frame-Options:Allow-From http://www.youtube.com'); 
header('X-Frame-Options:GOFORIT);
& amp; amp; output =嵌入到网址

阅读其他帖子中的某些解决方案。

但是我仍然得到相同的错误。



我也看到,youtube有对象的方法嵌入显示视频,但YouTube已经作为嵌入视频的旧方法。所以我想用新的iframe方法将视频嵌入到我的页面。



<问题见于
Firefox 11
Chrome 18.0
IE 8



有人遇到这个问题吗?



谢谢

解决方案

您设置的页面作为iframe的来源Youtube / watch 页面)不希望嵌入到您的页面中。你不能强迫它让你这样做。



要嵌入的正确网址格式为:

  http://www.youtube.com/embed/oHg5SJYRHA0 


I am trying to embed a youtube video on to my page once the user gives the link to the video.

<iframe width=\'560\' height=\'315\' src='http://www.youtube.com/watch?v=<video id>&amp;output=embed' frameborder=\'0\' allowfullscreen></iframe>

But when I try to add this I get this error. After inspecting the page in chrome, I see this error in the console tab

"Refused to display document because display forbidden by X-Frame-Options"

I am not able to see the video even in IE and Firefox also

I even tried adding the

 header('X-Frame-Options:Allow-From http://www.youtube.com'); 
 header('X-Frame-Options:GOFORIT);
 &amp;output=embed to the url

After reading certain solutions in other posts.

But I still get the same error.

I also see that the youtube has the method of object embedding to show the video, but already youtube has made that as old method of embedding the video.So I want use the new iframe method of embedding the video on to my page.

Problem is seen in Firefox 11 Chrome 18.0 IE 8

Anybody faced this problem ?

Thank you

解决方案

The page you're setting as the source of the iframe (the Youtube /watch page) doesn't want to be embedded in your page. You cannot force it to let you do that.

The correct URL to embed is of the form:

http://www.youtube.com/embed/oHg5SJYRHA0

这篇关于嵌入youtube视频“拒绝显示文档,因为X-Frame-Options禁止显示”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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