Foreign letters failing when sending emails

那年仲夏 提交于 2020-01-15 12:33:36

问题


I sometimes have to send emails in a German and I need to use ö ä ß etc... I have text written containing these letter and using alert() they appear just fine. I have code to send an email :

    var link = "mailto:" + SendTo
         + "&cc= " 
         + "&subject=" + escape(subjectLine)
         + "&body=" + escape(BodyText);
         window.location.href = link;

When I click a button to send the email, the text is missing these foreign letters e.g gruß comes out as gru. Do I need to put anything in here to make sure these letter don't disappear?

Thank you in advance


回答1:


The following articles shows how to decode the letters using javascript :

Javascript decoding html entities

function decodeHtml(html) {
    var txt = document.createElement("textarea");
    txt.innerHTML = html;
    return txt.value;
}

HTML Entity Decode

Using jquery:

varTitle = $('<textarea />').html("Chris&apos; corner").text();


来源:https://stackoverflow.com/questions/29005855/foreign-letters-failing-when-sending-emails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!