iframe无法在HTML中找到YouTube视频

时间:2013-11-17 14:55:33

标签: html iframe youtube

我正在设计一个关于儿童电影作业的网站,我想我会把一个iframe用来显示YouTube视频中的预告片。这是我使用的代码(只是测试视频);

<iframe width="560" height="315" src="//www.youtube.com/embed/xxMcViTf7KU" frameborder="0" allowfullscreen>This is the test iframe</iframe>

结果是页面开始加载,然后出现一个框,说“找不到文件或目录”。据我所知,代码都是正确的。我不明白什么是错的。

非常感谢任何帮助,谢谢!

2 个答案:

答案 0 :(得分:3)

在YouTube链接之前不要忘记“http://”。这工作正常:

<iframe width="560" height="315" src="http://www.youtube.com/embed/xxMcViTf7KU" frameborder="0" allowfullscreen>This is the test iframe</iframe>

答案 1 :(得分:0)

您可以尝试这样<embed-video></embed-video>

将其添加到index.html -

<script src="https://www.youtube.com/iframe_api"></script>

然后在你的html中使用:

 <div class="video-img-contr-2">
        <embed-video height="100%" width="100%" iframe-id="vimeo1" api="1" player_id="vimeo1" src="https://www.youtube.com/watch?v=qWiBjzY8j20">
              <a href="https://www.youtube.com/watch?v=qWiBjzY8j20">Watch</a>
        </embed-video>
     </div>

请参阅快照:

enter image description here

相关问题