[BUGFIX beta] Fix error with $.focus() on Firefox.

Firefox does not support calling `.focus()` if the window itself does not have
focus. See details [here](http://bugs.jquery.com/ticket/13363).

Resolves #3521.