When opening a window using JavaScript, it's possible to capture a reference to the opened window/tab, that can then be used to see if the window/tab has been closed again for example. Something like this (somewhat contrived example):
var foo = window.open( 'http://www.foo.bar' );
...
if ( !foo || foo.closed ) {
...
But is it possible to achieve something similar using anchor elements? For example, if I have the link
<a href="http://www.foo.bar" target="_blank">Foo</a>
on my website, is there any way to attach an event listener and obtain a reference to whatever window/tab is opened when this anchor element is triggered, and then use this in JavaScript? Listening to the click event could work, but are there other ways that cover it better? (For example, you can tab to an anchor element and press enter to open it too, which won't register as a click event)