简体   繁体   English

使用javascript电子邮件的最佳做法是什么?

[英]What is the best practice for e-mail by javascript?

I'm sending e-mail from a html form/text field. 我正在从html表单/文本字段发送电子邮件。 But OSX Safari does not import the main text into the email client like chrome does. 但是OSX Safari不会像chrome一样将主要文本导入电子邮件客户端。 What is the best practice for what I want to do, and how can I solve the compatability issue? 我想做什么的最佳实践是什么,如何解决兼容性问题?

This is the method I've used: 这是我使用的方法:

 function sendMail() { var link = "mailto:postto@myself.com" + "?cc=" + "&subject=" + escape("Inquiry via website") + "&body=" + escape(document.getElementById('input2000').value); window.location.href = link; } 
 <textarea id="input2000" name="message" placeholder="Write a message here."></textarea> <button type="button" id="formBtn" onclick="sendMail(); return false"> 

I want to click the button and fully fill out an email in the users preferred client. 我想单击按钮,并在用户首选的客户端中完全填写一封电子邮件。

Thanks for the comments! 感谢您的评论! Please also chip in your viewpoints of this method. 也请切合您对此方法的观点。 There are pros and cons to choosing this above mailing by server, or just using a traditional html mailto. 选择以上通过服务器发送邮件,或仅使用传统的html mailto都有优点和缺点。 I find it's good to get the user typing without leaving the browser, and then leaving just one click to ship the e-mail of in the end. 我发现最好让用户在不离开浏览器的情况下进行键入,然后只需单击一下即可发送最终的电子邮件。

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

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