【问题标题】:FancyBox - Reload Parent Page on Button ClickFancyBox - 单击按钮时重新加载父页面
【发布时间】:2014-02-13 06:13:03
【问题描述】:

我正在使用fancybox 在另一个页面(parent.htm)中显示一个页面(比如 child.htm)。

我知道如何自动reload the parent page after closing the iFrame

$(".fancybox").fancybox({
    afterClose : function() {
        location.reload();
        return;
    }
});

但是,我的要求更具体。仅当用户单击按钮时(例如:单击 child.htm 中的“确定”按钮),我才需要关闭 iframe,然后重新加载父页面(parent.htm)。

我遇到的代码 sn-p 的问题是,即使单击关闭图标或单击框架外的任何位置,父页面也会重新加载。这是我想要限制的东西。我的议程是仅在单击按钮时才导致页面刷新。

【问题讨论】:

    标签: javascript user-interface fancybox


    【解决方案1】:

    我会尝试这样的:

      $('.fancybox').fancybox({
          href : 'child.html',
          type : 'iframe',    
          afterShow: function(){     
            $('.fancybox-iframe').contents().find('#button').click(function(){
                 // do something
                 ...
    
                 // reload parent window and close fancybox
                 window.parent.location.reload();
                 window.parent.$.fancybox.close();
             }); 
           }
     });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-13
      • 2017-04-30
      • 2021-03-01
      • 1970-01-01
      • 2019-10-26
      • 2013-10-13
      • 1970-01-01
      相关资源
      最近更新 更多