Why does window.focus () not work in Mozilla firefox?

I need to focus on the window that opens on subsequent clicks on the anchor tag. I used this function below.

function newwindow(url) { OpenWin = this.open(url,"mywindow"); OpenWin.focus(); } 

OpenWin.focus () does not work in Mozilla Firefox. Is there any other solution for focusing on the window that opens on subsequent clicks on the anchor tag?

+2
source share
4 answers

You probably need to allow scripts to raise windows, since Firefox does not allow this by default.

On the Content tab of the Options dialog box, click the Advanced... button next to Enable Javascript , then in the dialog that appears, check the Raise and lower windows box.

+5
source

The checkbox no longer exists in newer versions of ff

The only way to change the setting is with the dom.disable_window_flip about: config parameter

+1
source

You can disable / enable Javascript window.focus event from Firefox options:

Go to "Tools"> "Options"> "Content"> "Advanced"> "Raise or Lower Windows"

It is not possible to overwrite this serveride option because it was created for this very purpose: to prevent windows from stealing focus. Your only option is to use model windows on top of your website, which are essentially β€œnew pop-ups”.

0
source

I assume that FF follows the HTML standard , which states the following:

. focus()

 Focuses the window. Use of this method is discouraged. Allow the user to control window focus instead. 

i.e. we cannot focus the window.

0
source

All Articles