开发者

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

开发者 https://www.devze.com 2023-01-23 11:41 出处:网络
I need to focus on window opened on further clicks on anchor tag. I have used the below function to do so.

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 Mo开发者_如何学Czilla Firefox. Is there any other solution to focus on window opened on further clicks on anchor tag?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消