EDIT: got it, it was the noopener noreferrer bit that stopped it.
This is in search.template.php [Tab 1]
I want the first link to open in new tab [Tab 2] and any consecutive links that are clicked on [Tab 1] to open in [Tab 2].
<li>
<a class="button_strip_print" href="https://www.google.com/search?q=', !empty($context['search_params']['search']) ? $context['search_params']['search'] : '', '" target="_blank" title="Google search" rel="noopener noreferrer nofollow"><span class="last">G</span></a>
</li>
I tried linking to an external js and renaming _blanks to mytarget, but did not do it.
var targetlinks = document.querySelectorAll('[target="mytarget"]');
var opentarget = function(e){
if( "mytarget" in window ){
mytarget.location.href = e.target.href;
}
else {
window.mytarget = window.open( e.target.href, 'mytarget' );
}
e.preventDefault();
};
[].slice.call( targetlinks ).forEach( function(link){
link.addEventListener('click', opentarget );
});
All you had to do was name the target the same each time; _blank opens in a new tab regardless, but a named target always opens in that target.
noopener noreferrer stops that, of course, and is also potentially a security measure you're getting rid of.
Yes, you are right, but I will have to make do with that, unless someone knows a different way of doing it that would preserve the security measures...