Open youtube video in Fancybox jquery

前端 未结 6 1761
有刺的猬
有刺的猬 2020-12-02 07:55

Can I open youtube video in fancybox.

I have a list of youtube videos links , for ex:



        
6条回答
  •  悲&欢浪女
    2020-12-02 08:45

    THIS IS BROKEN, SEE EDIT

    
    

    This way if the user javascript is enabled it opens a fancybox with the youtube embed video, if javascript is disabled it opens the video's youtube page. If you want you can add

    target="_blank"
    

    to each of your links, it won't validate on most doctypes, but it will open the link in a new window if fancybox doesn't pick it up.

    EDIT

    this, above, isn't referenced correctly, so the code won't find href under this. You have to call it like this:

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

    as covered at http://fancybox.net/blog #4, replicated above

提交回复
热议问题