onblur event not working with google chrome

后端 未结 3 2008
你的背包
你的背包 2021-01-01 03:27

I am trying to use onblur event to close a window. Its working fine in IE, Firefox and safari, but the event does not trigger in chrome. is that a bug in chrome or a mistak

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-01 04:01

    I realize this was over a year ago, but it showed up for me in Google while trying to solve this same issue.

    It seems Chrome does not consider some elements, like body and anchors, to be "focusable". According to the following page, you can make any element focusable (thereby activating the blur event) by setting the tabindex attribute: http://www.quirksmode.org/dom/events/blurfocus.html

    Like so:

     blur me 
    

提交回复
热议问题