播放 YouTube 视频的超链接 [英] Hyperlink to play youtube video
本文介绍了播放 YouTube 视频的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在您的网页上创建一个可以在同一页面上播放嵌入的 YouTube 视频的超链接.
Is it possible to create a hyperlink on your web page that can play an embedded youtube video on the same page.?
推荐答案
您可以使用 Youtube 播放器 API
如果您通读了该文档,您会发现拥有自己的控件和扩展播放器非常容易.
If you have a read through that document, you'll see it's pretty easy to have your own controls and extend the player.
示例
// Get element holding the video (embed or object)
var player = document.getElementById("myYouTubePlayer");
//Create a simple function and check if player exists
function play() {
if(player) {
player.playVideo();
}
}
然后在你的 HTML 中简单地
Then in your HTML simply
<a href="#" onclick="play()">Play Youtube Video</a>
这篇关于播放 YouTube 视频的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文