submit a form in a new tab

后端 未结 8 2032
我在风中等你
我在风中等你 2020-12-04 16:03

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?

相关标签:
8条回答
  • 2020-12-04 16:32

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

    <form>
      <input type="submit" formtarget="_blank"/>
    </form>
    
    0 讨论(0)
  • 2020-12-04 16:36

    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>
    
    0 讨论(0)
  • 2020-12-04 16:42
    <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...

    0 讨论(0)
  • 2020-12-04 16:43

    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');
    }
    
    0 讨论(0)
  • 2020-12-04 16:45

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

    0 讨论(0)
  • 2020-12-04 16:51

    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/

    0 讨论(0)
提交回复
热议问题