Last updated on March 29th, 2022 at 07:21 am
We are assigning a variable named childwin to window.open function and then just use childwin.close() to eventually close the child browser window that got opened from a parent.
childwin === 'undefined' , we verify if childwin variable is set. ie If a child window is opened.
As you can see above I am adding delete childwin, this is done to unset the variable childwin . Special logic to make sure that after a user click Child Window Close button for the first time to close a window and if they attempt to click on that button again then the script will go back to the initial check where the variable childwin was not set and alert the user with a message No Child Window Open