FancyBox iframe第二次关闭 [英] FancyBox Iframe not closing second time

查看:104
本文介绍了FancyBox iframe第二次关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道之前曾有人问过这个问题,但是我无法使我的代码正常工作.

我启动了我的幻想箱:

$(document).ready(function() {

            $('.fancybox').on('click', function(event) {
    event.preventDefault();
    $.fancybox({
        'type' : 'iframe',
        // hide the related video suggestions and autoplay the video
        'href' : this.href = this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1') + '&autoplay=1',
        'overlayShow' : true,
        'centerOnScroll' : true,
        'speedIn' : 100,
        'speedOut' : 50,
        'width' : 640,
        'height' : 480
    });
});

});

然后称为iframe:

<a class="fancybox fancybox.iframe" href="http://vimeo.com/123456">

但是,当我关闭弹出窗口,然后再次尝试打开该窗口时,视频没有显示,任何人都可以帮助我解决该问题,大多数解决方案都与'type':'inline'有关,并且无法与我的示例配合使用.

非常感谢,

解决方案

如果您使用的是fancybox v2.x,则脚本中不需要(过时)选项(v1.3.4).你宁愿做

1).将您的html设置为

<a class="fancybox" href="http://vimeo.com/123456">

...删除特殊类fancybox.iframe

2).添加辅助媒体js文件,例如:

<script type="text/javascript" src="../helpers/jquery.fancybox-media.js"></script>

...相应地设置路径

3).使用此脚本

jQuery(document).ready(function ($) {
    $('.fancybox').fancybox({
        helpers: {
            media: {}
        }
    });
});

...并为自己省去一些头痛.

请参见 JSFIDDLE

如果需要,可以添加一些其他API选项.检查 http://fancyapps.com/fancybox/#docs 以获得v2.x的选项

I know this question was asked before however I cannot get my code to work.

I have my fancybox initiated:

$(document).ready(function() {

            $('.fancybox').on('click', function(event) {
    event.preventDefault();
    $.fancybox({
        'type' : 'iframe',
        // hide the related video suggestions and autoplay the video
        'href' : this.href = this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1') + '&autoplay=1',
        'overlayShow' : true,
        'centerOnScroll' : true,
        'speedIn' : 100,
        'speedOut' : 50,
        'width' : 640,
        'height' : 480
    });
});

});

and then iframe is called:

<a class="fancybox fancybox.iframe" href="http://vimeo.com/123456">

But when I close popup and then try to open that again video is not showing up, could anyone help me to resolve it, most of solutions relates to 'type' : 'inline' and doesnt seams to work with my example.

Many thanks,

解决方案

If you are using fancybox v2.x, then you don't need the (obsolete) options (v1.3.4) in your script. You could rather do

1). Set your html like

<a class="fancybox" href="http://vimeo.com/123456">

... removing the special class fancybox.iframe

2). Add the helpers media js file like :

<script type="text/javascript" src="../helpers/jquery.fancybox-media.js"></script>

... set your path accordingly

3). use this script

jQuery(document).ready(function ($) {
    $('.fancybox').fancybox({
        helpers: {
            media: {}
        }
    });
});

... and save yourself some headaches.

See JSFIDDLE

You could add some more API options if you need them. Check http://fancyapps.com/fancybox/#docs for the options of v2.x

这篇关于FancyBox iframe第二次关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆