简体   繁体   中英

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

I'm sending e-mail from a html form/text field. But OSX Safari does not import the main text into the email client like chrome does. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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