javascript 拒绝在框架中显示“http://vimeo.com/27577981”,因为它将“X-Frame-Options”设置为“SAMEORIGIN”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17613801/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Refused to display 'http://vimeo.com/27577981' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'
提问by Rishi
I am trying to embed a video in embed tag But I am getting this error :
我正在尝试在嵌入标签中嵌入视频但我收到此错误:
Refused to display 'http://vimeo.com/27577981' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
for youtube link : http://www.youtube.com/watch?v=zBEYR69o2Aowhen i replace watch?v= with embed/ , it runs fine. But its is not necessary that video will be of youtube. So I want a unique solution for this.
对于 youtube 链接:http: //www.youtube.com/watch?v=zBEYR69o2Ao 当我用 embed/ 替换 watch?v= 时,它运行良好。但视频不一定是 YouTube 的。所以我想要一个独特的解决方案。
采纳答案by Quentin
As the error message says, you can't embed that page in a frame. Vimeo provide documentation on how to embed their player. Follow that.
正如错误消息所说,您无法将该页面嵌入到框架中。Vimeo提供了有关如何嵌入播放器的文档。按照那个。
<html>
<head>
<title>{page_title}</title>
</head>
<body>
<iframe src="https://player.vimeo.com/video/{video_id}" width="{video_width}" height="{video_height}" frameborder="0" title="{video_title}" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</body>
</html>
回答by Picard
I had the similiar problem
solution:
in short (at the moment) the embed url is:
我有类似的问题
解决方案:
简而言之(目前)嵌入的网址是:
//player.vimeo.com/video/
instead of:
代替:
//vimeo.com/27577981
for instance:
例如:
<iframe src="//player.vimeo.com/video/27577981?portrait=0" class="ivid" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
but as Quentin said check the vimeo documentation: http://developer.vimeo.com/player/embedding
但正如昆汀所说,请查看 vimeo 文档:http: //developer.vimeo.com/player/embedding
回答by Adrián Deccico
this is happening due to the website in the iframe is setting the X-Frame-Options header to: SAMEORIGIN
这是由于 iframe 中的网站将 X-Frame-Options 标头设置为:SAMEORIGIN
The only way to make this work is to get the web-site to either not set the header or to change the value to ALLOW-FROM your-uri
完成这项工作的唯一方法是让网站不设置标题或将值更改为 ALLOW-FROM your-uri
This is why you need to follow the Vimeo instructions to get it working, but obviously every site has to be treated independently.
这就是为什么您需要按照 Vimeo 说明进行操作才能使其正常工作,但显然每个站点都必须独立处理。
This policy is a security measure to avoid click hiHymaning. You can check more information here: https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
此政策是一项安全措施,可避免点击劫持。您可以在此处查看更多信息:https: //developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options