Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <!-- Notice. IFrame has got a type="text/html" attribute and enablejsapi=1 in the src -->
  <iframe type="text/html" height="360" width="640" src="https://www.youtube.com/embed/jNQXAC9IVRw?enablejsapi=1"></iframe>
</body>
</html>
 
// Getting IFrame element without id
var playerIframe = document.getElementsByTagName("iframe")[0];
// Futute player object
var yPlayer;
loadYouTubeApi();
// This function loads the IFrame Player API code asynchronously.
function loadYouTubeApi() {
  var tag = document.createElement('script');
  tag.src = "https://www.youtube.com/iframe_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
// This function initializes YouTube player
// after the API code downloads.
// Notice. We are passing playerIframe element retrieved above.
function onYouTubeIframeAPIReady() {
  yPlayer = new YT.Player(playerIframe, {
    events: {
      onReady: playVideo
    }
  });
}
// This function plays video without sound,
// once the player is ready.
function playVideo() {
  yPlayer.playVideo();
  yPlayer.mute();
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers