POST表单到新窗口

时间:2016-06-07 11:42:21

标签: javascript html

我将尽最大努力尝试解释我尝试实现的目标,基本上我要将表格发布到post_form_here.html然后再转到将主页重定向到redirect_main_page.html我需要表单将值发布到弹出窗口,然后将主页重定向到重定向页面。

 <form method="POST" onclick="window.open('POST_FORM_HERE.HTML', 'newwindow',
 'width=500,height=500');  return true;" action="REDIRECT_MAIN_PAGE.HTML">

这是我到目前为止所提供的内容,但是这会将表单发布到redirect_main_page.html而不是post_form_here.html。感谢您的帮助,我希望我已经解释了我想要达到的目标。

2 个答案:

答案 0 :(得分:2)

在表单中使用target =“_ blank”

<form action="demo_form.asp" method="get" target="_blank">    
</form>

如果你想像这样使用新窗口

<form method="post" 
           target="new_popup" 
           action="https://www.google.co.in/" 
           onsubmit="window.open('about:blank','new_popup','width=500,height=300');">

        <input type="text" />
        <input type="submit" />
    </form>

答案 1 :(得分:2)

试试这个

HTML

<form id="form">
    <input type="text" name="name" >
    <input type="text" name="age" >
    <input type="submit">
</form>

JS

var form = $("#form");
form.on("submit",function(){
    window.open("POST_FORM_HERE.html?" + form.serialize(), "newwindow", 'width=500,height=500');
    window.location.href = "/REDIRECT_MAIN_PAGE.html";
    return false;
})