Membuat Pop UP Yotube Modal





Contoh kode :

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <script src="http://code.jquery.com/jquery.min.js"></script>
  <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body>
  <!-- Open a modal dialog button -->
  <a href="#" data-toggle="modal" data-target=".video-dialog">How to Use Ask the Experts</a>

  <!-- Video Player Dialog -->
  <div class="modal fade video-dialog" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">
        <div class="modal-body">
          <div id="videoDialogPlayer" class="vidflex"></div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>

  <script>
    (function () {
      var el = document.createElement('script');
      el.src = "//www.youtube.com/iframe_api";
      var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(el, s);
     
      var videoDialogPlayer;
     
      window.onYouTubeIframeAPIReady = function () {
        videoDialogPlayer = new YT.Player('videoDialogPlayer', {
          height: '390',
          width: '640',
          videoId: '4HG6Ek_SyJs'
        });
      }
     
      $(function () {
        $('.video-dialog').on('shown.bs.modal', function () {
          videoDialogPlayer.playVideo();
        }).on('hide.bs.modal', function () {
          videoDialogPlayer.stopVideo();
        });
      });
    }());
  </script>
</body>
</html>


Smoga bermanfaat...........
Previous
Next Post »