开发者

Hyperlink to play youtube video

Is it possible to 开发者_运维知识库create a hyperlink on your web page that can play an embedded youtube video on the same page.?


you can easily do this with the Youtube Player 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.

Example

// 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();
    }
}

Then in your HTML simply

<a href="#" onclick="play()">Play Youtube Video</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜