如何获得window.focus()的,以工作在Firefox [英] How to get window.focus() to work in firefox

查看:203
本文介绍了如何获得window.focus()的,以工作在Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人对如何能够在Firefox中使用 window.focus()的线索? (27.0.1)。
我已经尝试了所有的关于:配置设置在那里,但仍然没有运气

Does anyone have a clue on how to be able to use window.focus() in FireFox? (27.0.1). I have tried all the about:config settings out there but still no luck.

我的code看起来是这样的:

My code looks something like this:

var wi = window.open('myUrl');
wi.focus();

== ==编辑

我试图让我的机器在FireFox这项工作,而不是任何其他用户,请
从标准的不要让用户决定或这取决于用户的设置为
我要得到这个为本地项目的工作:)

I'm trying to make this work in FireFox on my machine, not for any other users so please refrain from the standard "let your users decide" or "it depends on the user's settings" as I want to get this to work for a local project :)

推荐答案

工具>选项,内容区域,高级按钮右侧的启用JavaScript应该给你允许这种行为的选项。如果你是在Linux上,导航可能会略有不同。

Tools > Options, Content area, "Advanced" button to the right of "Enable JavaScript" should give you the option to allow this behavior. If you're on Linux, the navigation might be slightly different.

请注意,它通常被认为是最佳实践,以允许用户选择应当在焦点什么窗口

Note, it is generally considered best practice to allow the user to choose what window should be in focus.

编辑:

这是关于:配置你指的是:dom.disable_window_flip

This is about:config you're referring to: dom.disable_window_flip

在FF 27.0.1我能够通过提供窗口的名称和参数的选择对window.open,然后调用焦点打开与焦点的新窗口。

In FF 27.0.1 I am able to open a new window with focus by providing window name and option parameters to window.open, and then calling focus.

var wi = window.open('http://www.google.com', 'window_name', 'height=200,width=200');
wi.focus();

例如,在这里: http://jsfiddle.net/CLVh2/

有关Chrome的支持,你想看看:​​谷歌Chrome浏览器和QUOT; window.open&QUOT ;解决方法吗?

For Chrome support, you'll want to check out: Google Chrome "window.open" workaround?

编辑:FOR突片支撑

如果你想打开一个标签并给予FF(27.0.1)的标签焦点,而只是调用window.open(URL)没有给你想要的结果,请尝试检查了当我打开新的标签,马上切换到它选项。它可以在工具中找到>选项>标签

If you want to open a tab and give the tab focus in FF (27.0.1), and simply calling window.open('url') is not giving you the desired result, try checking the "When I open a new tab, switch to it immediately" option. It can be found in Tools > Options > Tabs

这篇关于如何获得window.focus()的,以工作在Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆