使用 iFrame 将 Youtube 频道嵌入到 HTML 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12040181/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:22:04  来源:igfitidea点击:

Embed a Youtube Channel into HTML with iFrame

htmliframeyoutube

提问by Pytagora

I'm trying to embed a Youtube channel into a HTML page.

我正在尝试将 Youtube 频道嵌入到 HTML 页面中。

For example I take this channel address: http://www.youtube.com/aaaa

比如我拿这个频道地址:http: //www.youtube.com/aaaa

I used this code:

我使用了这个代码:

<html>
<head>
</head>
<body>
    <iframe src="http://www.youtube.com/aaaa"></iframe> 
</body>
</html>

The problem is that it doesn't work. I tried with another site, and it works. What can be the problem?

问题是它不起作用。我试过另一个网站,它的工作原理。可能是什么问题?

回答by Po-Jen Lai

The problem seems to be induced by this URL:http://www.youtube.com/aaaa.

这个问题似乎是由这个网址引起的:http://www.youtube.com/aaaa。

I tried some other URLs and it works.

我尝试了一些其他的 URL,它的工作原理。

You can try some URLs easily here.

您可以在此处轻松尝试一些 URL 。



Try this:

尝试这个:

  <script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/youtube.xml&amp;up_channel=aaaa&amp;synd=open&amp;w=320&amp;h=390&amp;title=&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script>

回答by Clinton Ward

<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/aaaa" frameborder="0">
</iframe>

This was taken from youtube here

这是从youtube这里截取的

it appears IE (and others) can only use [youtube.com /embed/ videoID] (HTML5 Player) - at least the way I am implementing them.

看来 IE(和其他人)只能使用 [youtube.com /embed/ videoID](HTML5 播放器)——至少是我实现它们的方式。

回答by Clinton Ward

To display a gallery of thumbnails of your YouTube Channel's most recent videos, you can use an iframe:

要显示 YouTube 频道最新视频的缩略图库,您可以使用 iframe:

<iframe
    onload="javascript:this.style.height = this.contentWindow.document.body.scrollHeight + 'px';"
    scrolling="no"
    height="600"
    marginheight="0"
    frameborder="0"
    width="480"
    src="http://youtubechannelembed.com/gallery.php?vids=9&user=doitfordummies&row=3&width=150&margin_right=15&desc=100&title=30&views=1&likes=1&dislikes=1&fav=1">
</iframe>

回答by blasteralfred Ψ

Try this:

尝试这个:

<div name=iframe style="width:100%; height:635px; border:2px solid grey; overflow:hidden">
  <iframe src="http://yourchannel URL" style=width:100%; height:700px; margin-top: -65px" scrolling=true>
     If you can see this, your browser doesn't support iframes. Click <a href=http://mychannel.url>here to
     see my YouTube channel.</a>
</div>

This should embed complete youtube channel without youtube search bar.

这应该嵌入没有 YouTube 搜索栏的完整 youtube 频道。