Javascript Fancybox触发器点击

Javascript Fancybox触发器点击,javascript,jquery,triggers,fancybox,fancybox-2,Javascript,Jquery,Triggers,Fancybox,Fancybox 2,我试图让fancybox触发,如果url中有可用的哈希,问题是使用了不同的方法,其中一些方法是从firefox的错误控制台中的stackoverflow返回“c not available”。在这里可以找到我正在尝试的网站 . 非常感谢您的帮助 我尝试过的方法: 你必须做两件事: 1)。更改触发代码: 当前您正在使用此触发器: var thisHash = window.location.hash; if(window.location.hash) { $(thisHash).trig

我试图让fancybox触发,如果url中有可用的哈希,问题是使用了不同的方法,其中一些方法是从firefox的错误控制台中的stackoverflow返回“c not available”。在这里可以找到我正在尝试的网站 . 非常感谢您的帮助

我尝试过的方法:


你必须做两件事:

1)。更改触发代码:

当前您正在使用此触发器:

var thisHash = window.location.hash;
if(window.location.hash) {
    $(thisHash).trigger('mousedown').trigger('click');      
}
但是你对自己说,你尝试了这篇文章的解决方案,因此你的代码必须如下所示:

var thisHash = window.location.hash;
if(window.location.hash) {
    $(thisHash).fancybox().trigger('click');        
}
由于选择器
#infor
未绑定到fancybox(v1.3.4),因此在触发
单击之前,需要
绑定它

2)。在fancybox初始化后调用触发器代码。

还是不行?这是一个提升问题。您的触发代码当前位于文档的
部分,但是正在页面底部调用fancybox.js文件,因此即使按照上面的建议更改代码,也不会触发,因为fancybox尚未初始化

将代码放在fancybox调用和初始化之后、关闭
标记之前,如:

<script type='text/javascript' src='http://rojava.se/wp-content/plugins/easy-fancybox/fancybox/jquery.fancybox-1.3.5.pack.js?ver=1.5.5'></script>
<script type='text/javascript' src='http://rojava.se/wp-content/plugins/easy-fancybox/jquery.easing.pack.js?ver=1.3'></script>

<script type="text/javascript">
jQuery(document).on('ready post-load', easy_fancybox_handler );
jQuery.noConflict();
(function($) {
  $(function() {
    $('#footbuttoncontainer ').click(function() {
      container = $('#footcontentcontainer');
      if(container.height() > 20){
        $('#footcontentcontainer').animate({height:"0"}, 1000);
      } else {
        $('#footcontentcontainer').animate({height:"26vmin"}, 1000);
      }
    });
    var thisHash = window.location.hash;     
    if(window.location.hash) {
      $(thisHash).fancybox().trigger('click');
    }
  });
})(jQuery);
</script>
</body>

jQuery(document).on('ready post load',easy\u fancybox\u handler);
jQuery.noConflict();
(函数($){
$(函数(){
$(“#footbuttoncontainer”)。单击(函数(){
容器=$(“#footcontentcontainer”);
如果(容器高度()>20){
$('#footcontentcontainer')。设置动画({height:“0”},1000);
}否则{
$(#footcontentcontainer')。设置动画({height:“26vmin”},1000);
}
});
var thishhash=window.location.hash;
if(window.location.hash){
$(thishhash.fancybox().trigger('click');
}
});
})(jQuery);
注意我在fancybox初始化之后移动了您的完整代码块

现在可以看到它正在使用URL中包含的
散列


您的代码非常完美,请检查警报框是否触发,您现在使用的实际代码是什么?
触发器是否在
.ready()
方法中?@JFK是的,它在ready函数中,如spirar中所示code@sara除了fancybox触发器外,一切正常,但我认为你的顺序是正确的
var thisHash = window.location.hash;
if(window.location.hash) {
    $(thisHash).fancybox().trigger('click');        
}
<script type='text/javascript' src='http://rojava.se/wp-content/plugins/easy-fancybox/fancybox/jquery.fancybox-1.3.5.pack.js?ver=1.5.5'></script>
<script type='text/javascript' src='http://rojava.se/wp-content/plugins/easy-fancybox/jquery.easing.pack.js?ver=1.3'></script>

<script type="text/javascript">
jQuery(document).on('ready post-load', easy_fancybox_handler );
jQuery.noConflict();
(function($) {
  $(function() {
    $('#footbuttoncontainer ').click(function() {
      container = $('#footcontentcontainer');
      if(container.height() > 20){
        $('#footcontentcontainer').animate({height:"0"}, 1000);
      } else {
        $('#footcontentcontainer').animate({height:"26vmin"}, 1000);
      }
    });
    var thisHash = window.location.hash;     
    if(window.location.hash) {
      $(thisHash).fancybox().trigger('click');
    }
  });
})(jQuery);
</script>
</body>