且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

多次提交一个表单到一个新的标签

更新时间:2023-11-24 11:07:10

这似乎适用于webkit。不知道它如何为IE工作。

  $(#newsletter_form)。submit(function(){
$(#newsletter_form)。submit();
});


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. However, hitting the preview button only works once in Chrome/Safari.

I have searched, and found out that this is a bug in Chrome and 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. This still doesn't work. It works for IE and Firefox, just not in Webkit based browsers.

Is there any way to get around this?

This seems to work for webkit. Not sure how it will work for IE.

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