在iframe中嵌入视频?

时间:2015-04-01 17:35:24

标签: javascript html

我有以下代码来嵌入视频。但它不起作用。 有什么建议吗?

<!DOCTYPE html>
<html>
<body>

<iframe src="https://vimeo.com/63534746"></iframe>

</body>
</html>

2 个答案:

答案 0 :(得分:2)

您使用的链接指向视频页面,而不是视频“嵌入”页面。您可以使用网站的“共享”功能来获取正确的iframe代码:

enter image description here

答案 1 :(得分:1)

您在控制台中收到的错误是Refused to display 'https://vimeo.com/63534746' in a frame because it set 'X-Frame-Options' to 'sameorigin'.,因此Vimeo阻止您执行您要执行的操作。

X-Frame-Options有三种可能的值:

DENY - 无论网站是否尝试这样做,网页都无法在框架中显示。

SAMEORIGIN - 页面只能显示在与页面本身相同的原始帧中。

ALLOW-FROM uri - 页面只能显示在指定来源的框架中。

您可以使用Vimeo提供的嵌入代码(通过点击“分享”按钮找到),而不是嵌入整个页面。

<iframe src="https://player.vimeo.com/video/63534746?color=ffffff" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<p>
    <a href="https://vimeo.com/63534746">Light Bikes</a> from <a href="https://vimeo.com/ericcorriel">Eric Corriel</a> on <a href="https://vimeo.com">Vimeo</a>.
</p>