模糊事件不会在IE7和IE6中被触发 [英] Blur Event Does not get Fired in IE7 and IE6

查看:105
本文介绍了模糊事件不会在IE7和IE6中被触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉菜单,单击div中的一个,显示List。

I have a dropdown Menu where in a div is clicked and List is shown.

关注焦点我应该隐藏列表(即当用户点击或关注某些其他元素而不是鼠标移出时)。因此,我明显的选择是 onblur

On focus out I am supposed to hide the list(i.e. when the user clicks or focuses on some other element and not on mouse out). Hence my obvious choice was onblur.

现在JavaScript似乎在Firefox中工作但在IE中不起作用因为我的div有一个指定高度和宽度的子div。这在测试文件中是可重现的。我正在使用jQuery。

Now the JavaScript seems to work in Firefox but not in IE thats because my div has a sub div with a height and width specified. This is reproducible in a test file. I am using jQuery.

这是Internet Explorer中的已知问题吗?什么是工作?

Is this a known issues in Internet Explorer? And what is the work around?

<html>
  <head>
    <title>Exploring IE</title>
    <style type="text/css">
      /** Exploring IE**/
      .selected_option div {height:18px;}
    </style> 
    <script type="text/javascript" src="jquery-1.3.2.min9919.js"></script>
    <script type="text/javascript">
      $().ready(function(){
        $('.selected_option').blur(function(){
          alert('blurred');
        });
      });
    </script>
  </head>
  <body>
    <div class="selected_option" tabindex="0">
      <div>anywhere in the page</div>
    </div>
  </body>
</html>


推荐答案

IE专有重点突出为我工作的事件:

The IE-proprietary focusout event worked for me:

$('.selected_option').bind('focusout', function(){
    alert('focusout');
});

同样,这是专有的(参见 quirksmode )但如果它可以解决您的问题,则可能是合适的。你总是可以绑定到 blur focusout 事件。

Again, this is proprietary (see quirksmode) but may be appropriate if it solves your problem. You could always bind to both the blur and focusout events.

这篇关于模糊事件不会在IE7和IE6中被触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆