简体   繁体   English

多次将表单提交到新选项卡

[英]Submit a Form to a new Tab more than once

I am trying to build a simple form for sending a newsletter: 我正在尝试构建用于发送新闻稿的简单表单:

<form method="post" id="newsletter_form" action="">
        <label for="subject">Newsletter Subject:</label><br/>
        <input type="text" name="subject" class="textField large" id="subject" /><br/><br/>
        <label for="contents">Newsletter Contents:</label><br/>
        <textarea class="textField" rows="6" cols="40" name="contents" id="contents"></textarea>
</form>

And then two buttons, one of them sets the action to a preview page, and target to _blank, to open in a new tab, and then the other button sets another action, and removes the target, so that it submits normally and sends out the newsletter. 然后有两个按钮,其中一个将动作设置为预览页面,目标设置为_blank,以在新标签页中打开,然后另一个按钮设置另一个动作,并删除目标,以便其正常提交并发送出去新闻通讯。 However, hitting the preview button only works once in Chrome/Safari. 但是,点击预览按钮只能在Chrome / Safari中使用一次。

I have searched, and found out that this is a bug in Chrome and Safari. 我进行了搜索,发现这是Chrome和Safari中的错误。 However, I am trying to bypass this by creating another form using jQuery, with a different ID, removing the first form, and making the preview submit that second form. 但是,我试图通过使用具有不同ID的jQuery创建另一个表单,删除第一个表单,并使预览提交第二个表单来绕过此操作。 This still doesn't work. 这仍然行不通。 It works for IE and Firefox, just not in Webkit based browsers. 它适用于IE和Firefox,但不适用于基于Webkit的浏览器。

Is there any way to get around this? 有什么办法可以解决这个问题?

This seems to work for webkit. 这似乎适用于webkit。 Not sure how it will work for IE. 不确定如何将其用于IE。

$("#newsletter_form").submit(function(){
    $("#newsletter_form").submit();
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM