【问题标题】:iframe can't find YouTube videos in HTMLiframe 在 HTML 中找不到 YouTube 视频
【发布时间】:2013-11-17 14:55:32
【问题描述】:

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

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

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

任何帮助将不胜感激,谢谢!

【问题讨论】:

  • 您不想在 www.youtube 之前添加 //

标签: html iframe youtube


【解决方案1】:

不要忘记 YouTube 链接前的“http://”。效果很好:

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

【讨论】:

  • 非常感谢!我在编码时总是忘记这样做:/
【解决方案2】:

你可以像这样尝试&lt;embed-video&gt;&lt;/embed-video&gt;

将此添加到您的 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>

见快照:

【讨论】:

    猜你喜欢
    • 2020-04-19
    • 2020-03-01
    • 1970-01-01
    • 2017-04-11
    • 2018-02-12
    • 2016-07-25
    • 1970-01-01
    • 1970-01-01
    • 2016-05-15
    相关资源
    最近更新 更多