Greasy Fork is available in English.

Discussions » Creation Requests

Bring new window back in focus

§
Posted: 08. 06. 2014
Bring new window back in focus

Frequently when I open a link in a new window the new window starts opening and then goes behind the previous
window. I usually have to lower the original window so I can click the new window to bring it to the foreground.
Not all new windows act this way.

I don't know if a script could do this but I would like one which would bring the new window now immediately behind the original window back into focus, or one which would prevent the new window from losing its focus.

Thank you.
§
Posted: 08. 06. 2014
Edited: 08. 06. 2014
Ah, you mean pop-unders.
This could probably be done using window.focus() the difficult part would be detecting if the current window is a pop-under or not...
Perhaps a simple one-liner would do. A script that would always bring new popups into focus. Something simple like this?

// ==UserScript==
// @name Windows Always Focus
// @author Tommy Smith
// @description Makes new popups or pop-unders always become the focus, no matter what!
// @version 0.1
// @include http*://*
// ==/UserScript==

window.focus();

It's so crazy it just might work!
(I don't know how to format this properly...)
That said, one potential problem I can see is if a page automatically redirects elsewhere, it will come back into focus.
§
Posted: 09. 06. 2014
Edited: 09. 06. 2014
Firefox on Windows 7 or later? This could be a known bug in the protected mode of the Flash plugin. If all Flash processes have exited more than 3 minutes ago, the next window you open containing Flash will change the z-order and give focus back to the last active window. Annoying. See the following support thread for more background and known workarounds: https://support.mozilla.org/questions/955659
§
Posted: 10. 06. 2014
I am using Windows 8.1. Thanks for your suggestions I appreciate your help.
§
Posted: 12. 06. 2014
I decided not to use a userscript because of the potential problems mentioned in the
posts above. Instead to bring a hidden window back in focus I use this code

var ws = Services.wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
while(ws.hasMoreElements()) {
var w = ws.getNext();
if(w != window) {
w.focus();
break;
}
}

given to me by infocatcher on the custom buttons forum.
I run the code by a mouse gesture I assigned to it using the Firegestures addon, https://addons.mozilla.org/en-US/firefox/addon/firegestures/.
This works out well for me.

I appreciate the help and information I was given here. Thanks.

Post reply

Sign in to post a reply.