JSFiddle - React, Tailwind, and code Playground

by nitinjs

HTML

<a href="http://www.bing.com?q=" onclick="return openInTab($(this));">Open In Tab</a>

JavaScript

window.currentChild = false;

function openInTab($elm) {
    if (currentChild) currentChild.close();
    const child = window.open($elm.attr("href")+new Date(), "myWindowName", '');
    currentChild = child;

    //Scrope script in child windows
    child.frames.eval(`
    setInterval(function () {
        if (!window.opener.currentChild)
      		window.opener.currentChild = window;
    }, 500);
  `);
  return false;
}