Javascript表单提交打开新窗口选项卡,然后重定向父页面

Javascript表单提交打开新窗口选项卡,然后重定向父页面,javascript,php,forms,redirect,popup,Javascript,Php,Forms,Redirect,Popup,当我提交表单时,我试图打开一个新窗口选项卡,并将值传递到新窗口选项卡中。然后我需要父页面重定向到下一页 问题是表单值没有传递到新窗口选项卡。 我现在有下面的代码,我怎么能做到这一点呢 <form class="form" id="promo_form" method="post"> <input type="text" name="first_name" id="first_name"> <input type="text" name="last_name" id=

当我提交表单时,我试图打开一个新窗口选项卡,并将值传递到新窗口选项卡中。然后我需要父页面重定向到下一页

问题是表单值没有传递到新窗口选项卡。 我现在有下面的代码,我怎么能做到这一点呢

<form class="form" id="promo_form" method="post">
<input type="text" name="first_name" id="first_name">
<input type="text" name="last_name" id="last_name">
<input type="text" name="zipcode" id="zipcode" maxlength="5">
<button type="submit" id="promo_form_button" class="submit">Continue</button>
</form>


$(document).ready(function($){

var form = document.getElementById("promo_form");

    function goToUrl(){
        window.open("https://site.com/new-tab", "_blank");
        window.location = "https://site.com/parent-next-page"
    }

    document.getElementById("promo_form_button").onclick = goToUrl;
});

继续
$(文档).ready(函数($){
var form=document.getElementById(“promo_form”);
函数gotour(){
窗口打开(“https://site.com/new-tab“,”空白“);
window.location=”https://site.com/parent-next-page"
}
document.getElementById(“促销表单按钮”).onclick=gotour;
});

当表单可以针对新选项卡/窗口本身时,为什么要使用window.open

HTML:

<form target="_blank" method="get" action="http://google.com" id="myForm">
    <label for="q">Search: </label><input type="text" id="q" name="q" />
    <input type="submit" value="search" />
</form>
document.getElementById("myForm").onsubmit = function() {
    window.location.href = "http://www.jsfiddle.net";
    return false;
};
示例:

<form target="_blank" method="get" action="http://google.com" id="myForm">
    <label for="q">Search: </label><input type="text" id="q" name="q" />
    <input type="submit" value="search" />
</form>
document.getElementById("myForm").onsubmit = function() {
    window.location.href = "http://www.jsfiddle.net";
    return false;
};

这是一个更好的解决方案+1很可能是一种竞赛条件,@ShawnGrav有正确的想法来解决这个问题。通过设置
document.getElementById(“myForm”).target直接与目标游戏