【问题标题】:colorbox - close parent iframe and open new iframe lightboxcolorbox - 关闭父 iframe 并打开新的 iframe 灯箱
【发布时间】:2013-01-02 13:02:56
【问题描述】:

我使用 jquery 和 colorbox lightbox 插件在 ligthbox 中打开 iframe。

问题是:

  1. 我点击按钮打开我的主 iframe 灯箱
  2. 在主 iframe 灯箱内 - 有一个 .flash_shareable 类的按钮
  3. 当您单击时,它应该关闭父级(即主 iframe),然后打开一个它链接到的新 iframe

它正在关闭父 iframe,但它没有打开新的 iframe。

我的代码:

$(document).ready(function(){
        var y = $(document.body).height();
        var x = $(document).width();
        parent.$.colorbox.resize({innerWidth:x, innerHeight:y});

        $('.iframe').colorbox({iframe:true}); //ligthbox

        $(".flash_shareable").click(function() {
        parent.$.colorbox.close();
        $.colorbox({href:"faq.html", iframe:true, width:800 + "px", height:600 + "px", open:true});
    })
});

iframe 的 HTML,我试图从中打开另一个 ligthbox:

<button class="flash_shareable" type="button">open flash</button>

【问题讨论】:

    标签: jquery iframe colorbox parent-child


    【解决方案1】:

    我已修复它,但我仍然觉得需要一些东西 ^_^ 它在 Internet Explorer 8 及以下版本中不起作用,我希望任何人都可以帮助我直到?请:)

    $(document).ready(function(){
            var y = $(document.body).height();
            var x = $(document).width();
            parent.$.colorbox.resize({innerWidth:x, innerHeight:y});
    
            $('.iframe').colorbox({iframe:true}); //ligthbox
    
            $(".flash_shareable").click(function() {
    
            $.colorbox({href:"faq.html", iframe:true, open:true});
        })
    });
    

    【讨论】:

    • 尽量不要将colorbox附加到元素上,如下所示:$.colorbox({iframe:true, href: yourUrl});。并修复click函数末尾缺少的;
    • 我刚刚测试,它只适用于Firefox n IE9,不适用于Chrome或IE8。
    猜你喜欢
    • 1970-01-01
    • 2013-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多