【问题标题】:Refresh page when colorbox is closed关闭彩盒时刷新页面
【发布时间】:2012-02-26 02:37:08
【问题描述】:

我正在使用colorbox,我想在页面关闭时刷新页面,所以我尝试这样的事情:

    $.colorbox({href:"loading.html",title:'send notification...',escKey:false,width:300,height:00,
overlayClose:false,onClosed:location.reload(true)});
                $.ajax({
                   url: "sendNot.php",
                   type: "POST",
                   data: {titolo:titolo.value,messaggio:messaggio.value},
                   success: setTimeout("parent.$.colorbox.close()",5000)
                }); 

如果我删除 onclosed 选项,5 秒后颜色框将被删除,但是当 ajax 停止在帖子中加载页面时,对其执行类似代码将关闭。问题是什么?你能帮助我吗? 没有人? :(

【问题讨论】:

    标签: jquery ajax refresh colorbox


    【解决方案1】:

    试试这个:

    $.colorbox({href:"loading.html",title:'send notification...',escKey:false,width:300,height:00,
    overlayClose:false,onClosed:function() { location.reload(true); }});
    

    只是为了澄清区别 - 该插件允许您为 onClosed 事件提供回调函数,该函数必须是命名函数或匿名函数。这是一个匿名函数 - 您可以轻松地执行以下操作,以提高可读性/可重用性(在某些情况下)。请注意回调中缺少括号。

        $.colorbox({href:"loading.html",title:'send notification...',escKey:false,width:300,height:00,
        overlayClose:false,onClosed:reloadPage});
    
    function reloadPage() {
        location.reload(true); 
    }
    

    【讨论】:

      【解决方案2】:

      您还可以将刷新放在颜色框的原始调用中

      $(document).ready(function(){
          $('.iframe').colorbox({
              iframe:true,
              width:'700px',
              height:'800px',
              onClosed:function(){ location.reload(true); },
          }); 
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2022-11-21
        • 1970-01-01
        • 2011-08-21
        • 1970-01-01
        • 2022-06-17
        • 2013-02-22
        • 1970-01-01
        相关资源
        最近更新 更多