Submit a Form to a new Tab more than once

痴心易碎 提交于 2020-01-15 09:02:10

问题


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?


回答1:


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

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


来源:https://stackoverflow.com/questions/2024240/submit-a-form-to-a-new-tab-more-than-once

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