javascript - Magnific popup youtube video doesn't load - Stack Overflow

I have seen the other posts about this matter, and the suggestions made did not resolve the problem. So

I have seen the other posts about this matter, and the suggestions made did not resolve the problem. Some of the posts don't even have an answer. I posted this as an answer in one post, and it was deleted twice. I would appreciate it if the developper could help me out, as this is the place he has indicated to ask questions.

I have all the js files, and the image popups work just fine (indivudual and gallery). For the videop pop up I added this script to the page:

$(document).ready(function() {
$('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
    disableOn: 700,
    type: 'iframe',
    mainClass: 'mfp-fade',
    removalDelay: 160,
    preloader: false,

    fixedContentPos: false
});

});

And this code to the video link:

<a class="popup-youtube" href="">Video</a>

The popup opens but the video doesn't play. The youtube link is correct, as far as I know - I followed Dimitry's instructions for a clean link (e.g. and , neither works). The "jquery-1.2.6.min.js" file in my JS folder may be too old. Where can I find an updated version? Looked and can't find it. Totally self taught website builder here, please use simple language when explaining what the heck it is I'm doing wrong. Thank you in advance.

I have seen the other posts about this matter, and the suggestions made did not resolve the problem. Some of the posts don't even have an answer. I posted this as an answer in one post, and it was deleted twice. I would appreciate it if the developper could help me out, as this is the place he has indicated to ask questions.

I have all the js files, and the image popups work just fine (indivudual and gallery). For the videop pop up I added this script to the page:

$(document).ready(function() {
$('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
    disableOn: 700,
    type: 'iframe',
    mainClass: 'mfp-fade',
    removalDelay: 160,
    preloader: false,

    fixedContentPos: false
});

});

And this code to the video link:

<a class="popup-youtube" href="http://www.youtube./watch?v=qdMexQCi5-Q">Video</a>

The popup opens but the video doesn't play. The youtube link is correct, as far as I know - I followed Dimitry's instructions for a clean link (e.g. https://www.youtube./watch?v=qdMexQCi5-Q and http://www.youtube./watch?v=qdMexQCi5-Q, neither works). The "jquery-1.2.6.min.js" file in my JS folder may be too old. Where can I find an updated version? Looked and can't find it. Totally self taught website builder here, please use simple language when explaining what the heck it is I'm doing wrong. Thank you in advance.

Share Improve this question edited Nov 11, 2014 at 14:55 Paula Blank asked Nov 11, 2014 at 14:46 Paula BlankPaula Blank 11 silver badge2 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 3

Did you read this, it talks about having your code running in a server environment or using https://? As you said you followed Dmitrys' tutorial; he is using what we called protocol-relative URL (URL starting with "//") in his code so if you are running your code locally (by just opening the .html files with your browser) this will not work. You should use the solution given by Chris So of explicitly forcing either http:// or https:// instead of // the protocol-relative URL.

Seems like a dependency of magnificPopup is having jQuery 1.7.2 or later. http://plugins.jquery./magnific-popup/

You can update to a newer version from the jQuery webiste http://jquery./download/ or referencing the file online

<script src="//ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script

Try this. I hope this will help.

$(document).ready(function() {

$('.free_video_popup').magnificPopup({
    type: 'iframe',
    // other options
    iframe: {
        markup: '<div class="mfp-iframe-scaler">'+
                  '<div class="mfp-close"></div>'+
                  '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
                '</div>', 

        patterns: {
          youtube: {
            index: 'youtube./', 

            id: 'v=',

            src: 'https://www.youtube./embed/%id%' 
          },


        },

        srcAction: 'iframe_src', 
      }
  });

});

You need to adjust your link from http://www.youtube./watch?v=qdMexQCi5-Q, to http://www.youtube./embed/qdMexQCi5-Q, change /watch?= to /embed/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745380363a4625195.html

相关推荐

  • javascript - Magnific popup youtube video doesn&#39;t load - Stack Overflow

    I have seen the other posts about this matter, and the suggestions made did not resolve the problem. So

    6小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信