1<html> 2 <body> 3 <iframe id="player_frame" type="text/html" width="640" height="390" 4 src="" 5 frameborder="0"></iframe> 6 <br> 7 <script> 8 function play(video_url) { 9 document.getElementById('player_frame').src = video_url; 10 } 11 var tag = document.createElement('script'); 12 tag.src = "http://www.youtube.com/iframe_api"; 13 var firstScriptTag = document.getElementsByTagName('script')[0]; 14 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 15 var player; 16 function onYouTubeIframeAPIReady() { 17 new YT.Player('player_frame', { 18 events: { 19 'onReady': onPlayerReady, 20 } 21 }); 22 } 23 function onPlayerReady(event) { 24 player = event.target; 25 player.playVideo(); 26 } 27 </script> 28 </body> 29</html> 30