window.focus(), self.focus() not working in firefox

Firefox will only obey requests to raise a window if a security option is set, and it’s not set by default. Chrome won’t pay attention to focus() requests at all, as far as I can tell. Safari does obey focus() request.

The specific Firefox setting is in the “Tools” -> “Options” (“Edit -> Preferences” on Linux, maybe MacOS) dialog. There’s a “Content” tab, and in that there’s a checkbox for enabling Javascript. Along with that is an “Advanced” button that brings up another dialog, wherein one finds a checkbox to allow (or disallow) the raising and lowering of windows by page code.

edit: Here is a test page: http://gutfullofbeer.net/focus1.html and you should be able to see that Firefox will raise a window when the page calls window.focus(). You must either have the browser set up so that new windows (created with window.open()) open up in a new separate window instead of a tab, or else you can tear off the tab of the secondary page when it opens.

Leave a Comment