I have a web page with a link that opens another page in a new tab. In the newly opened page, I have a link that, when clicked, should bring focus to the original tab.
The new tab is opened via the target
attribute:
<a href="/new-page/" target="_BLANK">new tab</a>
I thought this should work:
<a href="#" class="back-link">switch tabs</a>
$('.back-link').click(function() {
if(window.opener) {
console.log('switching tabs');
window.opener.focus();
}
});
The console.log
fires, but focus stays on the current tab. What am I doing wrong?