HTML CSS examples for Bootstrap:Modal
Embed YouTube Video in Modal
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Example of Embedding YouTube Video inside Bootstrap Modal</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <style type="text/css"> <!--from www. j av a2 s. c om--> .modal-content iframe{ margin: 0 auto; display: block; } </style> <script type="text/javascript"> $(document).ready(function(){ var url = $("#cartoonVideo").attr('src'); $("#myModal").on('hide.bs.modal', function(){ $("#cartoonVideo").attr('src', ''); }); $("#myModal").on('show.bs.modal', function(){ $("#cartoonVideo").attr('src', url); }); }); </script> </head> <body> <div> <a href="#myModal" class="btn btn-lg btn-primary" data-toggle="modal">Launch Demo Modal</a> <div id="myModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h4 class="modal-title">YouTube Video</h4> </div> <div class="modal-body"> <iframe id="cartoonVideo" width="560" height="315" src="//www.youtube.com/embed/YE7VzlLtp-4" frameborder="0" allowfullscreen></iframe> </div> </div> </div> </div> </div> </body> </html>