Open a new tab with javascript but stay on current tab

Is it possible to open a new tab in Firefox (in background) using window.open("http://www.google.com") function, and remain the current tab?

Thanks for any help


You can't open tabs in the background using javascript because this is set in the user's preferences in about:config, which you have no control over. The setting is:

browser.tabs.loadDivertedInBackground=true

Whether or not to focus a new tab when it is opened is a browser setting and not something that you can control.

Opening links in a new tab at all (rather than a separate window) is a browser setting too, so you're facing an uphill battle with this one.

Basically, leave it up to the user to decide how they want to open links.


Here's an idea:

<script>
function open_in_bg(c_url, n_url)
{
 window.open (n_url, "mywindow" );
 window.open (c_url+"#maintain_focus","_self");
}
</script>

<input type="button" onclick="open_in_bg('current_page_url', 'url_to_be_opened')" />