2012-05-09 66 views
0

我想创建一个菜单,当你点击页面上的任何其他地方div将被隐藏。这在一切,但Firefox的作​​品。在Firefox中,当你点击该部分中的链接之一时,它不会进入链接,它只是关闭div。JavaScript点击和隐藏问题火狐

代码:

$(document).mouseup(function(e){//removes menu when clicked on any other part of page 
    if($(".menuone:visible").length > 0 ){ 
     $('.menuone').hide(); 
    } 
}); 

HTML:

<div class="menuone"> 
<div class="col1"> 
<ul><li>Example link</li></ul> 
</div> 
</div> 

回答

2

您应该建立可跟踪.menuone div的悬停状态的变量。

那么你的if语句将是:

if($(".menuone:visible").length > 0 && !menuHover) 

这应该做的伎俩。

希望它能帮助:)

编辑:

var menuHover = false; 

$(".menuone").bind('mouseenter mouseleave',function(e){ 
    menuHover = e.type == 'mouseenter'; 
}); 
+0

感谢这个意愿,但是这确实现在的工作 – meohmy

+0

您是否设置了一个函数来实际设置变量? – will

+0

不只是在顶部的编码 – meohmy

0

我喜欢John Resig's网站在这里提到的想法:

var outerPane = $details.find(".details-pane-outer"), 
    didScroll = false; 
$(window).scroll(function() { 
    didScroll = true; 
}); 

setInterval(function() { 
    if (didScroll) { 
     didScroll = false; 
     // Check your page position and then 
     // Load in more results 
    } 
}, 250);