Answer the question
In order to leave comments, you need to log in
How to make a YouTube frame in a popup?
Hello.
There are many videos on the page. It is necessary to optimize the work by uploading videos in a pop-up. Used plugins. Tried lightbox - doesn't work with frame. Fancybox - The jquery version does not stack with the one most of the site is linked to. Wrote this
<a href="#media-popup" data-media="http://www.youtube.com/embed/lgZBsWGaQY0?autoplay=1">asd</a></p>
<div class="popup" id="media-popup">
<iframe width="560" height="315" src="" frameborder="0" allowfullscreen></iframe>
</div>
$("[data-media]").on("click", function(e) {
e.preventDefault();
var $this = $(this);
var videoUrl = $this.attr("data-media");
var popup = $this.attr("href");
var $popupIframe = $(popup).find("iframe");
$popupIframe.attr("src", videoUrl);
$this.closest(".page").addClass("show-popup");
});
$(".popup").on("click", function(e) {
e.preventDefault();
e.stopPropagation();
$(".page").removeClass("show-popup");
});
$(".popup > iframe").on("click", function(e) {
e.stopPropagation();
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question