【问题标题】:close fancybox and open new one using functions关闭fancybox并使用函数打开新的fancybox
【发布时间】:2011-10-04 19:31:34
【问题描述】:

我有一个应用程序,我使用 Fancyboxes 通过 Fancyboxes 中的 IFRAMES 显示来自服务器的内容。因此,我希望在服务器中提交或更改数据后运行一个脚本,该脚本使用 IFRAME 调用当前的fancybox,以关闭并打开另一个包含新 url、大小和 iframe 的fancybox。

我通过各种谷歌网站尝试了几种不同的代码,但没有一个适用于我的应用程序。

我们将不胜感激!

更新:在这里找到答案:http://www.amitpatil.me/fancybox-runtime-resizing-of-iframe/

【问题讨论】:

    标签: php jquery iframe fancybox


    【解决方案1】:

    调用$.fancybox.closeparent.$.fancybox.close()(来自iframe),然后打开一个新的:

    $.fancybox({            
    'transitionIn'  : 'none',
    'transitionOut' : 'none',
    'width'     : 680,
    'height'        : 495,
    'href'      : 'http://example.com/new'
    });
    

    或者简单地调整fancybox的大小:$.fancybox.resize()。 这将帮助您调整大小:How do you resize Fancybox at runtime?

    [更新]

    据我了解:您已经用fancybox 打开了A.php。在 A.php 上,您可能有一个表单,并且该表单被提交给 B.php。如果是这种情况,您必须关闭+打开或仅通过 parent.$.fancybox.function_name 调整 B.php 的 document.ready 中的 fancybox。

    【讨论】:

    • 感谢您的快速解答。起初我正在寻找调整大小,不知道为什么我没有看到那个链接。
    • 很高兴为您提供帮助!如果答案有助于您解决问题,请考虑接受答案。
    • 抱歉,为了弄清楚这一点,在调用我的 PHP 操作并将所有内容发送到数据库之后,我只需调用 parent.$.fancybox.close() 来关闭fancybox,然后我将其他代码放在父页面中,它会自动打开一个新的fancybox?
    • 这是有道理的。我想会是这样。无论哪种方式,我都更喜欢调整大小选项。干净多了!
    【解决方案2】:

    不知道你是否试过这个,但似乎对我有用:

    parent.MyFunction(); // call this from the iframed url
    
    function MyFunction(){ // have this in your parent page
        // call your fancybox close function here
    } 
    

    【讨论】:

      【解决方案3】:

      @TamasPap 建议的方法对我不起作用,由于我花了数小时研究和试验,直到最终找到一种有效的方法,我想分享它。

      parent.$.fancybox.open({ href : 'iframe2.html', type: 'iframe'});
      parent.$.fancybox.close({ href : 'iframe1.html'});
      

      您可以在 type: 'iframe' 之后指定任何选项、助手或 css,方式与创建函数时相同。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-21
        • 2015-01-31
        • 2015-06-20
        • 1970-01-01
        相关资源
        最近更新 更多