submit a form in a new tab

陌路散爱 提交于 2019-11-28 16:35:20

问题


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?


回答1:


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




回答2:


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>  



回答3:


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

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



回答4:


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




回答5:


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

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



回答6:


Try using 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/




回答7:


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

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

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

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



回答8:


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



来源:https://stackoverflow.com/questions/5709590/submit-a-form-in-a-new-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!