Google Chrome duplicates JavaScript 'focus' event Google Chrome duplicates JavaScript 'focus' event google-chrome google-chrome

Google Chrome duplicates JavaScript 'focus' event


Creepy how these things can happen. I've run into this exact issue at work today, but have quickly written this off suspecting dodgy event listening and propagation in a 3rd-party plugin (jQuery customInput). I'll double-check your jsfiddle tomorrow.

I'm unable to recreate your exact output on my currently available setup (Chrome v17 on a Mac) but I do have a theory to share. In your scenario and in Ben Lee's comment the consistent part is shifting focus to another window (console in your case).

Check out http://www.quirksmode.org/dom/events/blurfocus.html under "Window + focusable element":

If the window is sent backward while a focusable element is focused, blur events should fire on both. If the window is brought forward again, focus events should fire on both.

And next, in the compatibility table it's noted that

Safari Windows fires two focus events.

Maybe Chrome finally got this "feature" too, coming from the Webkit family and all?


I was able to recreate the problem (using your jsFiddle) and from what I can see it only occurs when you click the select without having focus on/in the result frame.

Click within the frame but not on the selects before you click to expand one of the selects and you´ll only see one line logged.

You can also append /show to the jsFiddle URL to view the result in a separate window.

It seems like focusing the window by clicking on a select control triggers the event multiple times.

Open this demo and unfocus the browser window (by clicking the desktop, taskbar or another window) and then click on one of the selects to expand its options and view the console.

Using Chrome 17.0.963.79 m.