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 refere
To answer your question: I've found http://www.gtalbot.org/FirefoxSection/Popup/PopupAndFirefox.html#RaiseLowerSetting, which says the setting you're looking for is called "allow raise and lower windows".
Another setting would be about:config/dom.disable_window_flip
(to false), found here.
Expanding on Alex's contribution above. The use case is having a CMS. When a site owner is logged into the CMS, and the front end is loaded in another tab. You give the site owner a link on the front end that reloads the CMS tab and focuses is.
Place this javacript on front end pages (or include in a global JS file):
<script type="text/javascript">
// Stupid script to force focus to an existing tab when the link is clicked.
// And yes, we do need to open it twice.
function loadAdmin(a) {
var tab = window.open(a.href, a.target);
tab.close();
tab = window.open(a.href, a.target);
return false;
}
</script>
I like to put the CMS link just after the H1 content. Again, this is only if they are logged into the CMS. In this case I am pointing to a Framed CMS, so it has to know what to load into the main frame (pun intended).
<h1>
Page Heading
<a href="/admin/main/?load=pages/page.cfm?id=#request.pageid#" title="Edit this page"
onclick="return loadAdmin(this);"
target="#cgi.server_name#wvAdmin"
><img src="/media/admin/icon-edit.png" alt="Edit this page"/></a>
</h1>
This to make sure the tab is unique, in case I have several CMSs in my browser (support multiple clients):
target="#cgi.server_name#wvAdmin"
Finally, on the frame loader in the CMS, add this...
<script type="text/javascript">
window.name = '#cgi.server_name#wvAdmin';
</script>
... to ensure that if the user opened the CMS on their own, we can still work with it.
The simple answer is: you can't. Browsers doesn't expose that kind of API to javascript.
Have you tried window.focus()?
Opening new browser windows/tabs is problematic. Have you considered jqueryui dialogs instead of opening a new window?
There's no real way to do this for the simple reason that if websites had this ability, they'd end up using it to automatically focus ads or whatnot.
It can be done, but only in Firefox IF the user has it enabled, which he most likely won't.