Sri*_*kan 56 html javascript php security
我想在用户提供视频链接后,将YouTube视频嵌入到我的页面中.
<iframe width=\'560\' height=\'315\' src='http://www.youtube.com/watch?v=<video id>&output=embed' frameborder=\'0\' allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud)
但是当我尝试添加这个时,我得到了这个错误.在chrome中检查页面后,我在控制台选项卡中看到此错误
"因X-Frame-Options禁止显示器而拒绝显示文档"
我不能看视频,甚至在IE
和Firefox
也
我甚至试过加入
header('X-Frame-Options:Allow-From http://www.youtube.com');
header('X-Frame-Options:GOFORIT);
&output=embed to the url
Run Code Online (Sandbox Code Playgroud)
在其他帖子中阅读了某些解决方案后
但我仍然得到同样的错误.
我也看到youtube有对象嵌入的方法来显示视频,但是youtube已经将其作为嵌入视频的旧方法.所以我想使用新的iframe方法将视频嵌入到我的页面中.
问题出现在
有人遇到过这个问题吗?
dus*_*uff 178
您设置为iframe源代码的/watch
页面(Youtube 页面)不希望嵌入您的页面.你不能强迫它让你这样做.
要嵌入的正确URL的格式如下:
http://www.youtube.com/embed/oHg5SJYRHA0
Run Code Online (Sandbox Code Playgroud)
当您复制 YouTube 上的视频链接时:"https://www.youtube.com/watch?v=Fva3fgKmu3o"
将“观看”替换为“嵌入”
删除 '?v='
最后的例子:"https://www.youtube.com/embed/Fva3fgKmu3o"