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 mistake from me
Asked
Active
Viewed 2.1k times
7
-
are you trying to use window.onBlur? Could you provide a code example - it is easier for everyone to help you then. – Kinlan Apr 09 '10 at 12:07
-
You really should add a code example to your question – Black Apr 08 '16 at 11:54
3 Answers
9
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:
<a href="#" tabindex="0" onblur="alert('blur')"> blur me </a>

jkoreska
- 7,210
- 2
- 18
- 21
1
Just ran into this issue...
onBlur (with a capital "B") doesn't work, but onblur (lowercase "b") does. Go figure! ;-/

Jabari
- 5,359
- 3
- 26
- 32
-
1There's nothing in the language that suggests it's anything other than all lowercase. – The Muffin Man Jun 06 '13 at 04:58
-
3
0
Chrome accepts OnBlur event. what i have experience is... on check or uncheck of checkbox, chrome do not focus on it.
Add attribute
onclick="this.focus()" onblur="yourMethod()"/>
you will see it work fine then.

DaveShaw
- 52,123
- 16
- 112
- 141

zubair ali
- 11