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

Firefox does not support calling `.focus()` if the window itself does
not have focus.

Resolves #3521.
Merge pull request #3563 from rjackson/fix_firefox_error

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