精美框-如何在关闭iframe弹出窗口时刷新父页面? [英] Fancy Box - how to refresh parent page when close iframe popup?

查看:272
本文介绍了精美框-如何在关闭iframe弹出窗口时刷新父页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我关闭花式框"弹出框时,我希望刷新我的父页面.我在弹出窗口中有一个登录页面,因此我需要刷新父页面以在Fancy Box关闭时显示新的登录状态.

I want my parent page to refresh when I close a Fancy Box popup frame. I have a login page inside the popup, so I need the parent page to refresh to show the new login state when the Fancy Box closes.

我可以在没有iFrame代码的情况下使其正常工作:

I can get it to work without the iFrame code:

<script type="text/javascript">
 $(document).ready(function() {
  $("a.iframeFancybox1").fancybox({
   'width': 800,
   'height': 450,   
   'onClosed': function() {   
     parent.location.reload(true); 
    ;}
   });
 });
</script>


但是我无法使其与iFrame代码一起使用:


But I can't get it to work with the iFrame code:

<script type="text/javascript">
 $(document).ready(function() {
  $('a.iframeFancybox1').fancybox({
   'width': 800,
   'height': 450,
   'type' : 'iframe'
   'onClosed': function() {
     parent.location.reload(true); 
    ;}
   });
 });
</script>


问题在于此行:


The problem is to do with this line:


'type' : 'iframe'


我添加该行后,弹出窗口即停止工作.

As soon as I add that line, the popup stops working.


有人可以建议一个解决方法,使我可以在花式框中弹出一个iframe并在框关闭时仍然让父页面刷新吗? 谢谢!

Can anyone suggest a solution as to how I can get an iframe to popup in Fancy Box, and still get the parent page to refresh when the box closes?
 Thanks!

推荐答案

$(".fancybox").fancybox({
    type: 'iframe',
    afterClose: function () { // USE THIS IT IS YOUR ANSWER THE KEY WORD IS "afterClose"
        parent.location.reload(true);
    }
});

或者:

转到您的 jquery.fancybox.js 文件并转到 1380 行,如下所示,并添加parent.location.reload(true);

Go to your jquery.fancybox.js file and go line 1380 it is look like this and add parent.location.reload(true);

afterClose: function (opts) {
    if (this.overlay) {
        this.overlay.fadeOut(opts.speedOut || 0, function () {
            $(this).remove();
            parent.location.reload(true);
        });
    }
    this.overlay = null;
}

这篇关于精美框-如何在关闭iframe弹出窗口时刷新父页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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