Jyoti
Jyoti

Reputation: 2115

why window.focus() not working in Mozilla firefox?

I need to focus on window opened on further clicks on anchor tag. I have used the below function to do so.

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

OpenWin.focus() is not working on Mozilla Firefox. Is there any other solution to focus on window opened on further clicks on anchor tag?

Upvotes: 4

Views: 7975

Answers (4)

BeniBela
BeniBela

Reputation: 16907

The checkbox does not exist anymore in newer ff versions

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

Upvotes: 3

akond
akond

Reputation: 16035

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

window . focus()

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

i.e. we are not able to do the window focusing.

Upvotes: 0

Frédéric Hamidi
Frédéric Hamidi

Reputation: 262919

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

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

Upvotes: 5

Dennis G
Dennis G

Reputation: 21778

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

Go to Tools > Options > Content > Advanced > Raise or lower windows

There is no way to overwrite this option serverside, because it was made for exactly that purpose: Hindering windows from stealing focus. Your only option is to use model windows on top of your website, which are essentially "the new popup windows".

Upvotes: 0

Related Questions