In order to obtain a reference to the currently open window, I utilize the following code:
var refWindow = window.open("mypage1", "name_mypage");
If I wish to close the window, I simply use this command:
refWindow.close();
When I refresh the screen (by pressing F5) and execute the same line of code, the new content opens in the existing window since I have specified the same name.
var refWindow = window.open("mypage2", "name_mypage");
However, it is crucial to note that this creates a different reference (refWindow).
My question is: how can I assign a reference to the window based on its name? I need to close the current window before opening a new one with the same name.
One potential solution could involve performing the following steps:
var refWindow = window.open("about:blank", "name_mypage");
refWindow.close();
refWindow = window.open("mypage2", "name_mypage");
I am seeking an alternative method that achieves the desired outcome without requiring a blank window as a reference point.
Thank you.