【问题标题】:Not reload page when fancybox is open当fancybox打开时不重新加载页面
【发布时间】:2012-10-19 12:28:28
【问题描述】:

我是法国人,抱歉我的拼写错误...

我有一个包含fancybox 的页面,我想在所有分钟内重新加载此页面,除非打开了fancybox。该页面必须在fancybox关闭时再次充电。

我使用这段代码,当打开一个fancybox时,重新加载不会停止,fancybox的内容总是会重新充电。

var timeout
$(document).ready(function(){
   timeout = setTimeout('window.location.reload(true);',2000);
   $('.fancybox').fancybox({
      'beforeLoad': function() {if(timeout){clearTimeout(timeout); timeout = null; }},
      'beforeClose': function() {window.location.reload(true);}
   });          
});

有什么想法吗?

【问题讨论】:

    标签: jquery timeout fancybox reload fancybox-2


    【解决方案1】:

    使用 beforeLoadafterClose 这样对我有用:

    function reloadPage(){
     location.reload();
    }
    $(document).ready(function(){
     var timeOut = setInterval("reloadPage()", 5000);
     $(".fancybox").fancybox({
      beforeLoad: function(){
       clearInterval(timeOut);
      },
      afterClose: function(){
       location.reload();
      }
     });
    }); // ready
    

    WORKING DEMO HERE

    敬礼

    【讨论】:

      【解决方案2】:

      这应该可行。

      $("<your selector>").fancybox({
          afterClose: function() {
             var timeout = setTimeout('window.location.reload(true);',2000);
          },
          beforeShow:function(){
             if(timeout){ clearTimeout(timeout); timeout = null; }
          }
      })
      

      注意:fancy box的版本是jquery.fancybox.js?v=2.1.2

      请查看jsfiddle link

      【讨论】:

      • 感谢您的回复,但我不明白您的解决方案。可以举个例子吗?
      • 感谢您的帮助 Yadheendran。终于用JFK的代码了。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多