php 在新选项卡中提交表单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5709590/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:17:30  来源:igfitidea点击:

submit a form in a new tab

phpjqueryformshttp-post

提问by markzzz

I'd like (just to test some functions, after I'll avoid this behaviour) to load the page called by submit on a new tab : is it possible?

我想(只是为了测试一些功能,在我将避免这种行为之后)在新选项卡上加载由提交调用的页面:这可能吗?

回答by Strae

<form target="_blank" [....]

will submit the form in a new tab... I am not sure if is this what you are looking for, please explain better...

将在新选项卡中提交表单...我不确定这是否是您要查找的内容,请更好地解释...

回答by juanmf

I have a [submit] and a [preview] button, I want the preview to show the print view of the submitted form data, without persisting it to database. Therefore I want [preview] to open in a new tab, and submit to submit the data in the same window/tab.

我有一个 [提交] 和一个 [预览] 按钮,我希望预览显示已提交表单数据的打印视图,而不会将其持久化到数据库中。因此,我希望 [预览] 在新选项卡中打开,并提交以在同一窗口/选项卡中提交数据。

<button type="submit" id="liquidacion_save" name="liquidacion[save]" onclick="$('form').attr('target', '');">Save</button></div>    <div>
<button type="submit" id="liquidacion_Previsualizar" name="liquidacion[Previsualizar]" onclick="$('form').attr('target', '_blank');">Preview</button></div>  

回答by dragontree

It is also possible to use the new button attribute called formtargetthat was introduced with HTML5.

也可以使用formtargetHTML5 引入的新按钮属性。

<form>
  <input type="submit" formtarget="_blank"/>
</form>

回答by ThiefMaster

Add target="_blank"to the <form>tag.

添加target="_blank"<form>标签。

回答by SickHippie

Since you've got this tagged jQuery, I'll assume you want something to stick in your success function?

既然你已经有了这个标记的 jQuery,我会假设你想在你的成功函数中加入一些东西?

success: function(data){
    window.open('http://www.mysite.com/', '_blank');
}

回答by webtech

Try using jQuery

尝试使用 jQuery

<script type="text/javascript">
$("form").submit(function() {
$("form").attr('target', '_blank');
return true;
});
</script>

Here is a full answer - http://ftutorials.com/open-html-form-in-new-tab/

这是一个完整的答案 - http://ftutorials.com/open-html-form-in-new-tab/

回答by Link

This will also work great, u can do something else while a new tab handler the submit .

这也很有效,您可以在新选项卡处理程序 submit 时做其他事情。

<form target="_blank">
    <a href="#">Submit</a>
</form>

<script>
    $('a').click(function () {
        // do something you want ...

        $('form').submit();
    });
</script>

回答by ArtieJ

Your browser options must be set to open new windows in a new tab, otherwise a new browser window is opened.

您的浏览器选项必须设置为在新选项卡中打开新窗口,否则会打开一个新的浏览器窗口。