Forms 组合:打开mailto和表单提交

Forms 组合:打开mailto和表单提交,forms,post,onclick,mailto,Forms,Post,Onclick,Mailto,一次单击打开mailto窗口和一个post表单to test.php的组合不起作用。有什么建议吗 <form id="myForm" action="test.php" method="post"> <input type="hidden" name="someName" value="helloworld" /> <a href="mailto:..." onclick="document.getElementById('myForm').submit();"&

一次单击打开mailto窗口和一个post表单to test.php的组合不起作用。有什么建议吗

<form id="myForm" action="test.php" method="post">
<input type="hidden" name="someName" value="helloworld" />
<a href="mailto:..." 
onclick="document.getElementById('myForm').submit();">
Submit
</a>
</form>

选中下面的解决方案以忽略
href
属性,并将重点放在使用
onclick
只做您需要的事情上

函数提交(){
窗口。打开('mailto:mail@example.org","空白",;
document.getElementById('myForm').submit();
返回true;
}


@Wael:谢谢。第二个解决方案与此等效

<form id="myForm2" action="test.php" method="post">
<input type="hidden" name="someName" value="helloworld" />
<a href="mailto:mail@example.org" target="_blank" onclick="document.getElementById('myForm2').submit();">Submit 2</a>
</form>

缺少目标属性就是问题所在

在Firefox中,它可以根据需要工作。在铬中,它会导致 1.打开邮件客户端 2.发布到test.php 3.打开带有url mailto的新浏览器选项卡:mail@example.org(和重点)


对于您的第一个解决方案,它是相同的。如何避免3.?

当您使用
target=“\u blank”
时,会打开一个新的浏览器选项卡,当您有邮件客户端应用程序时,它会打开。是的,但如果没有target=“\u blank”,提交将不起作用。是的,As submit将重定向页面,如果您没有使用
target=“\u blank”