G
G
grinch_asd2018-12-03 18:49:20
YouTube
grinch_asd, 2018-12-03 18:49:20

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

spoiler

<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();
});
- error "does not permit cross-origin framing youtube". I read that this can be fixed by tweaking the url a little, but the problem is that the site on bitr and video will be added by the manager. How can this problem be solved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dymok, 2018-12-03
@grinch_asd

magnific popup

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question