关闭第二个窗口后重定向主窗口

Hello I completly edited my post

I have a main window , where i can select button that will open littel childs window :

 <div class="login-form">
  <div class="sign-in-htm">
    <div class="group">

      <button class="btn-3 loginBtn loginBtn--gbest" onclick="popupwnd('Pages/','no','no','no','no','no','no','300','300','500','500')">Login with Gbest</button>
    </div>

After the other page (is totaly filled and submit button's is clicked ) it will redirect to : a page where results will be stocked on the database and then close the window.

My problem is that : i want that after the child window is closed (to redirect the main page to another url ) https://gbest.com

I close my window using : echo "script/window.close()/script in the php folder that i use to stock in my databases the form information.

Thank you and sorry for the first post

Edit:

in 2nd window after your form is submitted or else you need to send a message to 1. window with javascript:

window.opener.postMessage('im done','https://yourdomain.com/main.php');

Than you need a message handler in window 1 like:

<script>
function receiveMessage(event)
{
  // Do we trust the sender of this message?  (might be
  // different from what we originally opened, for example).
  if (event.origin !== "http://yourdomain.com/form.php")
    return;

    if(event.data == 'im done'){
        // redirect your main window here
        }
}
window.addEventListener("message", receiveMessage, false);
</script>

This will only work if your form is opened from your main window.