I am developing a widget which ac开发者_JAVA百科tually allows user to add youtube videos, different users should be able to add different videos. For Example if user A can add say "x" video, he just need to copy and paste it and user B can add say "y" video. I am providing a textbox to paste the you tube video link. I am using jquery at the front end.
You can use jQuery to create a iframe and set the source to the youtube video url.
like this:
$("#somebutton").click(function(){
var srcurl = $("#textbox").val();
$("#mydiv").html("<iframe title=\"YouTube video player\" width=\"640\" height=\"390\" src=\"" + srcurl + "frameborder=\"0\" allowfullscreen></iframe>");
});
精彩评论