1

First of all, happy holidays to everyone.

I have an anchor element that fires two page redirects - one through the href attribute, one through jQuery.

<a id="myClick" target="_blank" href="http://www.google.ca">Google</a>

$('#myClick').on('click', function () {
    window.location = 'http://www.stackoverflow.com';
});

This works fine, but the new tab gains focus. I'd like the original tab to keep the focus for the user. I did give window.focus() a go but, as assumed, it didn't work.

I also did try working with the fiddle from this answer but it only fired the new tab and the original page (jsfiddle) remained the same URL. My edited Fiddle from linked answer

How could I go about having the original tab keep the focus? Is it out of my hands?

Community
  • 1
  • 1
Drew Kennedy
  • 4,118
  • 4
  • 24
  • 34

1 Answers1

0

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