焦点标签或窗口 [英] Focus tab or window

查看:112
本文介绍了焦点标签或窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个小应用程序,我从我的脚本打开几个窗口/选项卡。不管浏览器是打开一个窗口还是一个标签,当然都不在我手里。



但是,我保存了对新创建的窗口的引用对象,我从另一个窗口远程更改其内容。这一切都发生在同一个 document.domain 所以没有xss的问题。



问题是,我不能可靠 focus 创建的窗口/选项卡。由于我正在为客户编写一个非常具体的应用程序,因此我只将Firefox作为浏览器。我有一个选择当然只是做一个 remoteWindow.alert('foobar'); 来把窗口/标签放在前面,但这很丑陋,我发现这个答案 -alert>如何将焦点窗口/选项卡像alert()?



据说,Firefox有一个允许脚本焦点的选项。所以最后我的问题是,这是什么选择?
我搜索了 about:config 作为tabs和focus,但没有找到任何相关的内容。 b

如何配置?

解决方案我看到的唯一解决方案是强制弹出窗口,似乎没有办法集中另一个选项卡。此解决方案还要求您更改工具>中的默认Javascript安全设置。选项>内容标签然后点击启用Javascript 复选框旁边的高级按钮,然后检查中间框允许聚焦窗口。

要强制使用窗口而不是选项卡,请使用 win = window.open(http://www.google.com ,test,modal = yes); 然后调用 win.focus(); p>

编辑:其实忘记提及这只是FF的事实。


for a little app, I'm opening a few windows/tabs from my script. Whether the browser opens a window or a tab is of course not in my hand.

However, I hold the references to the newly created window objects and I do change their content "remotely" from another window. This all happens under the same document.domain so no xss problem.

The problem is, I cannot reliably focus those created windows/tabs. Since I'm writing a very specific app for a customer, I'm only targeting Firefox as browser. One option I have is of course just to do a remoteWindow.alert('foobar'); to get bring that window/tab up front, but that is pretty ugly isn't it.

I found this answer How to focus window/tab like alert()?

and it's said there, that Firefox has an option to allow script focus. So finally my question is, what is that option ? I searched the about:config for "tabs" and "focus" but didn't find anything related.

How to configure ?

解决方案

The only solution I see, is to force the popup in a new window, since there doesn't seem to be a way to focus another tab. This solution also requires you to change the default Javascript security settings in Tools > Options > Content tab and click on the Advanced button next to Enable Javascript checkbox and check the middle box to allow focusing windows.

To force the use of a window rather than a tab, use win = window.open("http://www.google.com", "test" ,"modal=yes"); and then call win.focus(); whenever you feel like it.

EDIT: Actually forgot to mention the fact that this is FF only.

这篇关于焦点标签或窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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