@Alexfixer

Как завершить и закрыть видео после закрытия модального окна?

Как заверишить и закрыть видео после закрытия модального окна?

<a href="#" class="btn btn-default" data-toggle="modal" data-target="#videoModal" data-theVideo="http://www.youtube.com/embed/loFtozxZG0s" >VIDEO</a>

      <div class="modal fade" id="videoModal" tabindex="-1" role="dialog" aria-labelledby="videoModal" aria-hidden="true">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-body">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">Закрыть&times;</button>
              <div>
                <iframe id="myModal" width="100%" height="350" src=""></iframe>
              </div>
            </div>
          </div>
        </div>
      </div>


$(document).ready(function(){
  autoPlayYouTubeModal();
});


//FUNCTION TO GET AND AUTO PLAY YOUTUBE VIDEO FROM DATATAG
function autoPlayYouTubeModal(){
  var trigger = $("body").find('[data-toggle="modal"]');
  trigger.click(function() {
    var theModal = $(this).data( "target" ),
    videoSRC = $(this).attr( "data-theVideo" ), 
    videoSRCauto = videoSRC+"?autoplay=0" ;
    $(theModal+' iframe').attr('src', videoSRCauto);
    $(theModal+' button.close').click(function () {
        $(theModal+' iframe').attr('src', videoSRC);
    });   
  });
}
  • Вопрос задан
  • 67 просмотров
Пригласить эксперта
Ответы на вопрос 1
@VadimFilimonov
Убрать src у iframe.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы