【问题标题】:How to Setup Mailto link in IE11?如何在 IE11 中设置 Mailto 链接?
【发布时间】:2019-08-14 12:04:04
【问题描述】:

我正在设置一个带有mailto 链接的 HTML 表单。它在 Google Chrome 中运行良好,并在 Outlook 中预填充表单正文。但是当我在 Internet Explorer 11 中执行相同操作时,电子邮件正文未填充。Example form is here

这是 IE11 设置的问题吗?还是我错过了什么?

【问题讨论】:

标签: html internet-explorer


【解决方案1】:

我已经重现了我这边的问题,好像我们在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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-31
    • 2015-06-05
    • 2014-07-04
    • 2013-10-17
    • 2017-05-08
    • 1970-01-01
    • 2010-10-11
    • 2011-06-10
    相关资源
    最近更新 更多