Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 关闭第二个窗口后重定向主窗口_Javascript_Php_Redirect - Fatal编程技术网

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

Javascript 关闭第二个窗口后重定向主窗口,javascript,php,redirect,Javascript,Php,Redirect,你好,我完全编辑了我的帖子 我有一个主窗口,我可以选择按钮打开littel childs窗口: <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','n

你好,我完全编辑了我的帖子

我有一个主窗口,我可以选择按钮打开littel childs窗口:

 <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>

使用Gbest登录
在另一个页面(完全填充并单击submit按钮)后,它将重定向到:一个将结果存储在数据库中的页面,然后关闭窗口

我的问题是:我希望在关闭子窗口之后(将主页重定向到另一个url)

我使用php文件夹中的:
echo”script/window.close()/script
关闭窗口,该文件夹用于在数据库中存储表单信息

感谢您并为第一篇帖子感到抱歉

编辑:

在提交表单后的第二个窗口中,或者您需要向1发送消息。使用javascript的窗口:

window.opener.postMessage('im done','https://yourdomain.com/main.php');
在窗口1中需要一个消息处理程序,如:

<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>

函数接收消息(事件)
{
//我们信任此邮件的发件人吗?(可能是)
//例如,与我们最初打开的不同)。
如果(event.origin!==”http://yourdomain.com/form.php")
返回;
如果(event.data=='im done'){
//将主窗口重定向到此处
}
}
window.addEventListener(“消息”,receiveMessage,false);

只有在从主窗口打开表单时,此操作才有效。

您好,您不明白我没有2个按钮,但2页是我所说的窗口,我想要包含按钮的页面(打开表单窗口)填写并提交表单后,我关闭窗口,然后我希望将第一页重定向到另一个链接抱歉,我认为这不会填充,我确实编辑了我的所有问题,以明确我的问题所在。我尝试了这一方法,效果很好。在窗口之间进行通信的唯一方法是postMessage。