【发布时间】:2019-08-14 12:04:04
【问题描述】:
我正在设置一个带有mailto 链接的 HTML 表单。它在 Google Chrome 中运行良好,并在 Outlook 中预填充表单正文。但是当我在 Internet Explorer 11 中执行相同操作时,电子邮件正文未填充。Example form is here
这是 IE11 设置的问题吗?还是我错过了什么?
【问题讨论】:
我正在设置一个带有mailto 链接的 HTML 表单。它在 Google Chrome 中运行良好,并在 Outlook 中预填充表单正文。但是当我在 Internet Explorer 11 中执行相同操作时,电子邮件正文未填充。Example form is here
这是 IE11 设置的问题吗?还是我错过了什么?
【问题讨论】:
我已经重现了我这边的问题,好像我们在IE浏览器中点击“发送”按钮发送邮件时,url只包含mailto属性(没有邮件正文),不会附加电子邮件正文到 url。因此,电子邮件正文为空。
为了解决这个问题,我建议你可以收集邮件信息,然后对邮件进行编码(参考W3's URL Encoding),最后发送邮件。代码如下:
<script>
window.onload = function () {
var eTo = encodeURI("sales@example.com"); // get the receiver
var eSubj = encodeURI("Submission From Quote Creator"); //get the email submit.
var emailbody = "Please enter your contact information and message here: \n\n\nQuote:\n#17350 IFW 2-inch -$829.00\n"; //get the email body.
var eBody = encodeURI(emailbody.replace("#","23%"));
var email = "mailto:" + eTo + "?subject=" + eSubj + "&body=" + eBody;
console.log(email);
document.getElementById("sales").href = email;
}
</script>
<a href="" id="sales">send email</a>
【讨论】: