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 fo
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')" />
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.
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
I know you said JavaScript, OP, but, I feel the heart of the matter for you is just opening the html links in and of themselves in a new tab.
In which case, simple add ' target="_blank" ' inside your link tags:
<a href="example.com" target="_blank"> random stuff</a>