如何将 YouTube 视频放在同一站点上 [英] How to put youtube video on the same site

查看:32
本文介绍了如何将 YouTube 视频放在同一站点上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你去守望先锋官网(https://playoverwatch.com/en-us/) 并单击WATCH TRAILER"按钮,YouTube 视频将显示在同一网站上,而无需将您定向到该视频来自的原始 youtube 页面.他们是怎么做到的?

If you go to the official website of Overwatch (https://playoverwatch.com/en-us/) and click on the "WATCH TRAILER" button, the youtube video will appear on the same website without having to direct you to the original youtube page where that video came from. How did they do that?

推荐答案

它被称为使用嵌入视频.你可以使用 iframes

It's called using embed videos. you can do it with using iframes

YouTube 视频 ID

当您打开视频时,YouTube 会显示一个 id(如 vhjTYfG).您可以使用此 ID,并在 HTML 代码中引用您的视频.

YouTube will display an id (like vhjTYfG), when you open video. You can use this id, and refer to your video in the HTML code.

要在网页上播放您的视频,请执行以下操作:

- Upload the video to YouTube
- Take a note of the video id
- Define an <iframe> element in your web page
- Let the src attribute point to the video URL
- Use the width and height attributes to specify the dimension of the player
- Add any other parameters to the URL (see below)

这是一个示例代码,

 <iframe width="420" height="315"
src="https://www.youtube.com/embed/vhjTYfG">
</iframe> 

*在这里阅读更多.w3schools

这篇关于如何将 YouTube 视频放在同一站点上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆