在表单提交,mailto从javascript与表单值

在表单提交,mailto从javascript与表单值

问题描述:

我有一个表单,当提交表单时(输入类型=提交),我想用预先填充的电子邮件打开客户端默认邮件浏览器。

I have a form, and when the form is submitted (input type="submit"), i would like to open the clients default mail-browser with a pre-populated email-message.

因此,当用户点击提交时,需要做两件事。打开电子邮件并提交表格。

So when the user clicks submit two things need to happen. Open email and submit form.

此外,我如何使用表格中输入的值预填充电子邮件?

Also, how can i use the values entered in the form to prepopulate the email?

我是javascript-jquery的新手所以请,任何代码示例都会有很大的帮助!

I'm new to javascript-jquery so please, any code example would be of great help!

感谢您的帮助!

在提交表格之前,您可以这样做:

Before submitting the form you could do:

 window.location.href = 'mailto:nicola@mio.it';

这将打开预定义的邮件客户端,您也可以预填一些字段。请查看mailto sintax 此处或发布更多信息,以便我们为您提供帮助;

this will open the predefined mail client and you can also prefill some field. look at the mailto sintax here or post some more info so that we can help you;

这可以这样做:

$('input[type=submit]').click(function(){
     window.location.href = "mailto:" + $('#email').val();
});