IE6 bug using blur and focus on form events
Par Goulven le lundi 27 juillet 2009, 11:55 - Blog - Lien permanent
While developping SelectOverflow (a Mootools plugin for long selects), IE6 fired the blur event when I said focus(). Here's how I circumvented the bug.
Setup
When the user focuses on a text input, the hidden select is shown and focused. When the select is blurred, it is hidden.
Bad IE6 behaviour
The first time the text input was clicked, the select didn't show up. What was weird, adding alert() in the code that displays the select solved the bug... Anyway, after some testing I found out that when IE6 encountered select.focus(), it fired the blur event instead, but only the first time.
Fixing it
Just before calling select.focus(), I call input.focus(). This shouldn't have any unwanted effect because the input is already focused at that time, and doing this prevents IE6 from firing select.blur instead of select.focus.

