admin管理员组

文章数量:1287505

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?

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?

Share Improve this question edited Jan 4, 2014 at 18:17 BenMorel 36.6k51 gold badges205 silver badges336 bronze badges asked Nov 3, 2010 at 9:15 JyotiJyoti 2,1153 gold badges27 silver badges30 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

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.

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

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".

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.

本文标签: javascriptwhy windowfocus() not working in Mozilla firefoxStack Overflow