I am opening multiple URLs in same tab which works well once but as soon as I refresh the source page from where the new tab was opened it opens new tab, any workaround for this?
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;
}
Scenario1:
- click on
Open In Tab
link, it will open a new tab - again click on
Open In Tab
link, it will close the previously opened tab and open a new tab
Scenario2:
- click on
Open In Tab
link, it will open a new tab - again click on
Open In Tab
link, it will close the previously opened tab and open a new tab - refresh the source jsfiddle page
- click on
Open In Tab
link, it will open a new tab (Expected closing previously opened tab)
Fiddle here: https://jsfiddle.net/nitinjs/a1zd2kuh/11/