Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Fancybox自动关闭,但仍由用户控制_Javascript_Jquery_Fancybox - Fatal编程技术网

Javascript Fancybox自动关闭,但仍由用户控制

Javascript Fancybox自动关闭,但仍由用户控制,javascript,jquery,fancybox,Javascript,Jquery,Fancybox,我已经在论坛上搜索过了,但找不到解决方案。 我引用此线程来执行自动关闭功能: ... 我确实遵循了JFK的解决方案,该解决方案非常有效: 'onComplete': function() { $("#fancybox-wrap, #fancybox-overlay").delay(3000).fadeOut(); } 如果不希望用户关闭该框,请添加modal=true 场景是,我希望用户可以选择关闭 当他们单击[关闭]按钮或单击屏幕上的任意位置时 覆盖我正在Rails上使用

我已经在论坛上搜索过了,但找不到解决方案。 我引用此线程来执行自动关闭功能: ... 我确实遵循了JFK的解决方案,该解决方案非常有效:

'onComplete': function() { 
   $("#fancybox-wrap, #fancybox-overlay").delay(3000).fadeOut(); 
   } 
如果不希望用户关闭该框,请添加modal=true

场景是,我希望用户可以选择关闭 当他们单击[关闭]按钮或单击屏幕上的任意位置时 覆盖我正在Rails上使用最新版本的FB和jQuery

这是我的剧本:

<script type="text/javascript"> 
  jQuery(document).ready(function() { 
    jQuery("#link_post").fancybox({ 
      'autoDimensions':false, 
      'width':380, 
      'height':50, 
      'title':'This message box will automatically close in 10 
seconds.', 
      'titlePosition':'outside', 
      'onComplete': function() { 
        jQuery("#fancybox-wrap, #fancybox- 
overlay").delay(10000).fadeOut(); 
      } 
    }); 
  }); 
</script> 

jQuery(文档).ready(函数(){
jQuery(“#link_post”).fancybox({
“自动标注”:false,
“宽度”:380,
身高:50,,
'title':'此消息框将在10分钟后自动关闭
秒,
“标题位置”:“外部”,
“onComplete”:函数(){
jQuery(#fancybox包装,#fancybox-
叠加)。延迟(10000)。衰减();
} 
}); 
}); 
但是,当我单击close按钮时,标题和close 按钮将淡出,但FB的内容和覆盖仍然是 那里它只会在10秒后消失。所以,我的问题是 如果用户单击关闭按钮,如何覆盖“onComplete”功能
按钮,然后自动关闭?

好的,我找到了解决方案。仅供参考,我使用的是fancybox v1.3.1和jQuery v1.4.2

<script type="text/javascript"> 
  jQuery(document).ready(function() { 
    jQuery("#link_post").fancybox({ 
      'autoDimensions':false, 
      'width':380, 
      'height':50, 
      'title':'This message box will automatically close in 10 
seconds.', 
      'titlePosition':'outside', 
      'onComplete': function() { 
        jQuery("#fancybox-wrap, #fancybox- 
overlay").delay(10000).fadeOut(); 
      } 
    }); 

    jQuery("#fancybox-close").click(function() {
      jQuery('#fancybox-overlay').stop();
      jQuery('#fancybox-wrap').stop();
    });

  }); 
</script> 

jQuery(文档).ready(函数(){
jQuery(“#link_post”).fancybox({
“自动标注”:false,
“宽度”:380,
身高:50,,
'title':'此消息框将在10分钟后自动关闭
秒,
“标题位置”:“外部”,
“onComplete”:函数(){
jQuery(#fancybox包装,#fancybox-
叠加)。延迟(10000)。衰减();
} 
}); 
jQuery(“fancybox关闭”)。单击(函数(){
jQuery(“#fancybox overlay”).stop();
jQuery(“#fancybox wrap”).stop();
});
}); 

好的,我找到了解决方案。仅供参考,我使用的是fancybox v1.3.1和jQuery v1.4.2

<script type="text/javascript"> 
  jQuery(document).ready(function() { 
    jQuery("#link_post").fancybox({ 
      'autoDimensions':false, 
      'width':380, 
      'height':50, 
      'title':'This message box will automatically close in 10 
seconds.', 
      'titlePosition':'outside', 
      'onComplete': function() { 
        jQuery("#fancybox-wrap, #fancybox- 
overlay").delay(10000).fadeOut(); 
      } 
    }); 

    jQuery("#fancybox-close").click(function() {
      jQuery('#fancybox-overlay').stop();
      jQuery('#fancybox-wrap').stop();
    });

  }); 
</script> 

jQuery(文档).ready(函数(){
jQuery(“#link_post”).fancybox({
“自动标注”:false,
“宽度”:380,
身高:50,,
'title':'此消息框将在10分钟后自动关闭
秒,
“标题位置”:“外部”,
“onComplete”:函数(){
jQuery(#fancybox包装,#fancybox-
叠加)。延迟(10000)。衰减();
} 
}); 
jQuery(“fancybox关闭”)。单击(函数(){
jQuery(“#fancybox overlay”).stop();
jQuery(“#fancybox wrap”).stop();
});
}); 
这是工作!对于fancybox v2.x

这是工作!对于fancybox v2.x