我有一个按钮可以触发以下 javascript 函数:
function sendEmail() {
var mail = 'mailto:[email protected] /cdn-cgi/l/email-protection';
location.href = mail;
};
在 Chrome 中,此函数会触发 HTTP GET 到“mailto:”[电子邮件受保护] /cdn-cgi/l/email-protection',但 HTTP GET 在“检查元素网络”选项卡中具有“已取消”状态,并且电子邮件客户端未打开。
在 IE 中,电子邮件客户端也打不开。
如何打开电子邮件客户端?
这个对我有用。但你可以试试这个
function sendEmail() {
var mail = 'mailto:[email protected] /cdn-cgi/l/email-protection';
var a = document.createElement('a');
a.href = mail;
document.body.appendChild(a); // Add to the DOM
a.click();
document.body.removeChild(a); // Remove it back
};
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)