I want to open a new tab, if it has not been opened before. If it has been already opened from the same opener, then show the tab (bring to front without reloading).
My code:
const openWindow = window.open(undefined, 'WindowName');
if (openWindow.location.href === 'about:blank') {
openWindow.location.href = newWindowUrl;
}
In Chrome this will open a new tab and set the url. Calling the same code again, will reopen the already available window, without reload.
In Firefox, this will open a new tab and set the url. Calling the same code again, will do nothing.
How can I reopen the available window by window.name?
The solution for FireFox is:
const openWindow = window.open(undefined, 'WindowName');
if (openWindow.location.href === 'about:blank') {
openWindow.location.href = newWindowUrl;
}
// ==> to open existing window in Firefox
openWindow.focus();