0

I'm trying to open a Youtube link in a lightbox using this code:

<a href="#" onclick="$.fancybox( ['http://www.youtube.com/watch?v=123'] );">Click me</a>

The lightbox fires, but instead of a Youtube player, it's just static text of the URL.

4

1 に答える 1

0

HTMLマークアップ

 <a class="video"  title="The Falltape" href="http://www.youtube.com/v/ZeStnz5c2GI?fs=1&amp;autoplay=1"><img src="images/1.jpg" alt="" /></a>

jQueryマークアップ

jQuery(document).ready(function() {

   $(".video").click(function() {
       $.fancybox({
         'padding'      : 0,
         'autoScale'    : false,
         'transitionIn' : 'none',
         'transitionOut': 'none',
         'title'        : this.title,
         'width'        : 640,
         'height'       : 385,
         'href'         : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
         'type'         : 'swf',
         'swf'          : {
             'wmode'            : 'transparent',
             'allowfullscreen'  : 'true'
          }
       });

       return false;
   });
});

使用されたコードは、グーグル検索で見つかりました。http://webdesignandsuch.com/fancybox-youtube-videos/

于 2012-09-24T05:05:11.567 に答える