Javascript 如何在新窗口中提交表单,然后重定向父页面

Javascript 如何在新窗口中提交表单,然后重定向父页面,javascript,html,forms,onsubmit,Javascript,Html,Forms,Onsubmit,我在这里尝试执行的操作存在一些浏览器兼容性问题 我在网页上有一个表格: <form method="POST" target="_blank" onsubmit="refreshparent()" action="https://processor.com/payment.php" > <input type="HIDDEN" name="unit_key" value="92393d" > <input type="H

我在这里尝试执行的操作存在一些浏览器兼容性问题

我在网页上有一个表格:

 <form method="POST" target="_blank" 
       onsubmit="refreshparent()" action="https://processor.com/payment.php" >
       <input type="HIDDEN" name="unit_key" value="92393d" >
       <input type="HIDDEN" name="cost" value="100.20" >
       <input type="HIDDEN" name="user_id" value="92393d" >
       <input type="SUBMIT" name="SUBMIT"  value="Click to open payment site" >
 </form>

当用户提交表单时,我希望打开一个新窗口,并调用名为“refreshparent”的javascript函数

  <script type="text/javascript">
       function refreshparent()
       {
           alert("test");
           window.location.replace ("http://mysite.com/main-menu.html");
        }
  </script>

函数refreshparent()
{
警报(“测试”);
window.location.replace(“http://mysite.com/main-menu.html");
}

这在某些浏览器中有效,但在Chrome中不起作用。有没有更好的方法让表单提交和javascript调用从同一个按钮单击中发生

不要使用
target=''blank'
来打开新窗口,只需阻止默认的提交操作并使用
窗口即可。打开
。不确定,但这可能会解决您的Chrome问题。

什么在Chrome中不起作用?空白标签、重定向、表单提交按钮在所有浏览器中的新窗口/选项卡中成功打开。但在Chrome中,页面不会重定向到。是的,我收到了警报,但没有重定向。我想知道在按下submit按钮后焦点是否移到了新窗口。