如何创建一个打开窗口的Mailto共享按钮,其中一个窗口可以输入要发送到的电子邮件地址 [英] How to Create a Mailto Share Button that Opens a Window in which Ones Can Enter Email Address to Send to
问题描述
我一直在网上搜索,了解如何创建一个 mailto
分享按钮,打开一个新窗口,用户可以在其中键入他选择发送到的电子邮件地址。我附上了一系列连续的图像作为操作示例:
I've been searching all over the internet to find out how to create a mailto
share button that opens up a new window in which the user can then type in the email address of his choice to send to. I've an attached a sequential set of images as operational example:
这是什么诀窍?为什么我找不到关于如何编写这样的代码的任何信息.... Stack Overflow上绝对没有!
What is the trick to this? Why can't I find any info on how to write such code ....absolutely nowhere on Stack Overflow either!
截至目前这是我的代码拥有:
As of right now this is the code that I have:
$('.share-page-on-Email').click(function() {
window.open("mailto:"+emailTo+'?cc='+emailCC+'&subject='+emailSub+'&body='+emailBody, '_self');
});
在我的代码笔中查看我的原型电子邮件分享按钮: https://codepen.io/IDCoder/full/rpdBQJ/
View my prototype Email share button at my Code Pen here: https://codepen.io/IDCoder/full/rpdBQJ/
提前感谢您的帮助!
推荐答案
我建议永远不要使用那个mailto:功能,因为它的行为不可预测,在不同设备上有所不同有时会失败。您可以创建一个页面,只是为了获取电子邮件字符串,然后在服务器端执行任何操作。使弹出/弹出窗口像:
I recommend never using that mailto: feature as it behaves unpredictably, different on different devices and sometimes fails alltogether. You could create a page just to take the email string then do whatever you want with it server side. Make the popup/popover small like:
<a href="/my-email-collector-page"
onclick="window.open(this.href,'targetWindow',
'toolbar=no,
location=no,
status=no,
menubar=no,
scrollbars=yes,
resizable=yes,
width=200px,
height=120px');
return false;">email</a>
这篇关于如何创建一个打开窗口的Mailto共享按钮,其中一个窗口可以输入要发送到的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!