Have Window Keep Focus After One Click Fires Two Page Redirects

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?



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:



Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.